Hi!

Recently, I've discovered the inject functionality in vibe.d and I find it pretty neat. It allows to systematize the way aliases are pulled down to the diet templates.

However, it has a limitation.

Consider the authentication sample from the doc

void authInjector(alias Next, Aliases...)(HTTPServerRequest req, HTTPServerResponse res)
{
	string userinfo;
	// TODO: fill userinfo with content, throw an Unauthorized HTTP error etc.
	Next!(Aliases, userinfo)(req, res);
}

void page(Aliases...)(HTTPServerRequest req, HTTPServerResponse res)
{
	string message = "Welcome to the example page!"
	res.render!("home.dt", Aliases, message);
}

static this()
{
	auto router = new URLRouter;
	router.get("/", inject!(page, authInjector));
} 

What TODO hides could be a request to a database. So, one needs somehow to access the DB object inside authInjector.

The preferable solution, I believe, would be to have authCheck a member function of some class which has a db object as a member. But that's impossible with the current inject implementation since you need 'this' to call authCheck.

Could someone advice on how to approach the problem? (Making db object global will work, but is not very pretty)