Am 03.06.2012 21:05, schrieb simendsjo:

On Sun, 03 Jun 2012 12:13:49 +0200, Sönke Ludwig wrote:

Actually, now I think this is actually really cool!the request and optionally not call the next injector, but return or
throw an HttpServerError. With this, the system is basically very
similar to node.js' connect framework.

Its now in vibe.templ.utils. I will also refactor some of my code to
use it when I have time.

I don't know any node.js, but it's a very convenient function.
A problem is that you cannot easily get the parameters from the request
This could be solved by adding an AA containing indexes to parameters by
void f(size_t[string] paramIndexes, Params...)(Request, Response)
A CTFE function / mixin template should be able to take care of adding
the correct indexes and calling the next injector, but I'm not sure this
is a good design :)

This should work:

mixin(localAliases!(0, VARS));

with localAliases as defined in

template localAliases(int i, ALIASES...)

static if( i < ALIASES.length ){
	enum string localAliases = "alias ALIASES["~cttostring(i)~"] 

"~__traits(identifier, ALIASES[i])~";\n"

~localAliases!(i+1, ALIASES);

} else {

enum string localAliases = "";


Also not really pretty but it works and it's just one line.