Function 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.
Prototype
vibe .web .common .PathAttribute path(
string data
);
See Also
rootPathFromName
for automatic name generation.
Example
@path("/foo")
interface IAPI
{
@path("info2") string getInfo();
}
class API : IAPI {
string getInfo() { return "Hello, World!"; }
}
void test()
{
import vibe .http .router;
import vibe .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());
// ...
}
Authors
Sönke Ludwig, Михаил Страшун
Copyright
© 2012-2014 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.