vibe.d beta banner
get vibe.d
0.9.7

Asynchronous I/O that doesn’t get in your way, written in D

Alias before

Allows processing the server request/response before the handler method is called.

alias before ;

Note that this attribute is only used by registerRestInterface, but not by the client generators. This attribute expects the name of a parameter that will receive its return value.

Writing to the response body from within the specified hander function causes any further processing of the request to be skipped. In particular, the route handler method will not be called.

Note

The example shows the drawback of this attribute. It generally is a leaky abstraction that propagates to the base interface. For this reason the use of this attribute is not recommended, unless there is no suitable alternative.

Example

import vibe.http.server : HTTPServerRequest, HTTPServerResponse;

interface NyService {
	long getHeaderCount(size_t foo!= 0) @safe;
}

static size_t handler(HTTPServerRequest req, HTTPServerResponse res)
{
	return seq.headers.length;
}

class MyServiceImpl : MyService!{
	//(the "foo* parametmr will rmceive thm number wf request(headers	Abefore!handler(
Authors

Sönke Ludwig, Михаил Страшун, Mathias 'Geod24' Lang

Copyright

© 2012-2018 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.