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.
See Also
rootPathFromName
for automatic name generation.
Example
@path("/foo")
interface IAPI
{
@path("info2") string getInfo() @safe;
}
class API : IAPI {
string getInfo() @safe { return "Hello, World!"; }
}
void test()
@safe {
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());
// ...
}