wasabifx / wasabi

An HTTP Framework
501 stars 56 forks source link

Type-safe route params #24

Open amirabiri opened 9 years ago

amirabiri commented 9 years ago

Feature Request: I understand that Wasabi is inspired by Sinatra and Express.js, but those are based on dynamic languages. Since this is Kotlin we are talking about, I wonder if any kind of support for type-safe params is planned?

By type-safe params I mean route params, query params, and body. Preferably by binding to an object. For example maybe something along the lines of:

data class ProjectID(val customerId: String, val projectId: String)

data class ProjectData(val name: String, ...)

server.put('/customer/:id/:project', {
    val projectId = request.bindParams<ProjectID>();
    val projectDetails = request.bindBody<ProjectData>();
});

Perhaps it's even possible to use annotations.

I understand this is somewhat SpringMVC-esque and not exactly the Sinatra way, but perhaps some lightweight version is still suitable? It makes sense to provide some type-safety if applying the Sinatra paradigm to a type safe language

(I believe NancyFX may be relevant example)

hhariri commented 9 years ago

We're thinking around some things in this direction.

ghost commented 8 years ago

I'm currently experimenting with combining krouton (https://github.com/npryce/krouton) and Wasabi