Struct InjectedParams
Makes the variable aliases passed to one of the injectors of the inject
!() template accessible
to the local function.
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);
}
Authors
Sönke Ludwig
Copyright
© 2012 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.