vibe.d beta banner
get vibe.d
0.10.0

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

Alias after

Allows processing the return value of a handler method and the request/response objects.

alias after = vibe.internal.meta.funcattr.after;

The value returned by the REST API will be the value returned by the last @after handler, which allows to post process the results of the handler method.

Writing to the response body from within the specified handler function causes any further processing of the request ot be skipped, including any other @after annotations and writing the result value.

Example

import vibe.http.router;
	import vibe.http.server;
import vibe.web.rest;

	interface MyService {
		long getMagic() @safe;
	}

	static long handler(long ret, HTTPServerRequest req, HTTPServerResponse res)
	@safe {
		return ret * 2;
	}

	class MyServiceImpl : MyService{
		// the result reported by the REST API will be 42
		@after!handler
		long getMagic()
		{
			return 21;
		}
	}

	void test(URLRouter router)
	@safe {
		router.registerRestInterface(new MyServiceImpl);
	}
Authors

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

Copyright

© 2012-2018 Sönke Ludwig

License

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