request

Returns the current request.

Note that this may only be called from a function/method registered using registerWebInterface.

@property @safe
request
()

Examples

void requireAuthenticated()
{
	auto authorization = "Authorization" in request.headers;

	enforceHTTP(authorization !is null, HTTPStatus.forbidden);
	enforceHTTP(*authorization == "secret", HTTPStatus.forbidden);
}

class WebService {
	void getPage()
	{
		requireAuthenticated();
	}
}

void run()
{
	auto router = new URLRouter;
	router.registerWebInterface(new WebService);

	auto settings = new HTTPServerSettings;
	settings.port = 8080;
	listenHTTP(settings, router);
}

Meta