path

Attibute to force a specific URL path.

This attribute can be applied either to an interface itself, in which case it defines the root path for all methods within it, or on any function, in which case it defines the relative path of this method. Path are always relative, even path on interfaces, as you can see in the example below.

@safe
path
(
string data
)

Examples

@path("/foo")
interface IAPI
{
	@path("info2") string getInfo();
}

class API : IAPI {
	string getInfo() { return "Hello, World!"; }
}

void test()
{
	import vibe.http.router;
	import hb.web.rest;

	auto router = new URLRouter;

	// Tie IAPI.getInfo to "GET /root/foo/info2"
	router.registerRestInterface!IAPI(new API(), "/root/");

	// Or just to "GET /foo/info2"
	router.registerRestInterface!IAPI(new API());

	// ...
}

See Also

rootPathFromName for automatic name generation.

Meta