vibe.d beta banner
get vibe.d
0.7.30

Struct InjectedParams

Makes the variable aliases passed to one of the injectors of the inject!() template accessible to the local function.

Template arguments

struct InjectedParams(Aliases);

Examples

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 somethingInjector(alias Next, Aliases...)(HTTPServerRequest req, HTTPServerResponse res)
{
	// access the userinfo variable:
	if( InjectedParams!Aliases.userinfo.length == 0 ) return;

	// it's also possible to declare a pseudo-
	// variable like this to access the parameters:
	InjectedParams!Aliases params;
	if( params.userinfo == "peter" )
		throw Exception("Not allowed!")

	Next!(Aliases)(req, res);
}
block ddox.authorsblock ddox.copyrightblock ddox.license
Authors
Copyright
License