On Wed, 25 Mar 2015 17:00:37 GMT, Jakob Øvrum wrote:
REST interfaces appear to have a number of ways to specify a prefix for the pages defined in the class. I'm trying to figure out ways to do it for web interfaces.
I've tried:
- vibe.web.common.rootPath
- vibe.web.common.rootPathFromName (with an ugly class name :P)
- vibe.web.web.WebInterfaceSettings.urlPrefix (this one seems to be missing documentation. What does it do?)
In all cases, the pages were still mapped to /. The first one does say in the docs that it's for REST interfaces (why?), yet they're still in vibe.web.common...
What is the best way to do this?
I was hoping for something like:
@rootPath("/web/v1") class MyWebInterface { void home() { render!"home.dt"; } }
or just
router.registerWebInterface(new MyWebInterface, "/web/v1"); // Ala REST interfaces
Both accessible like
/web/v1/home
.
Hm, we should definitely support the @path
and @rootPathFromName
attributes for registerWebInterface
, too, maybe it's also possible to move the related code to vibe.web.common
in the process. I've opened an enhancement request: #1036
Currently the way to specify a prefix is using WebInterfaceSettings
:
auto s = new WebInterfaceSettings;
s.urlPrefix = "/web/v1";
router.registerWebInterface(new MyWebInterface, s);