Am 14.09.2013 15:58, schrieb simendsjo:

Hi. I got time to play a bit with UDAs and vibe, and while this isn't much, I think the possibilities for more declarative code looks good.

 module myapp;
 mixin CurrentModule;

 @(page.get("/")) void index(HTTPServerRequest req, HTTPServerResponse res) {
     res.renderCompat!"index.dt"();
 }

 shared static this() {
     auto router = new URLRouter();
     router.addRoutesFromMembersOf!__CurrentModule;
 }

Notice @(page.get"/") and addRoutesFromMembersOf!__CurrentModule.

Next up is trying to fix UDAs for the inject pattern. Hopefully I can write the following

 @(page.get("/"))
 @(requires!(userLoggedIn, hasRights!(addUser)))
 void add_user(Params...)( // etc

Is anyone else playing around with UDAs and vibe?

The vibe.http.form module is supposed to be extended in that direction
(basically it shall get the same UDA support that vibe.http.rest
already has). Once this is finished, it would mean that the use case you
outlined is possible + support for automatic form to parameter
conversion. The interface also needs to be extended a bit for non-member
functions and a few other things, too.