On Fri, 09 May 2014 07:17:43 GMT, Sönke Ludwig wrote:
On Fri, 09 May 2014 06:29:36 GMT, Darius Clark wrote:
Hi,
I would like to ask about registerFormInterface(). I read several examples (including whats in the unittest) but I would like to get a clear answer:
First off, for new code, I'd strongly recommend to use the newer
vibe.web.webmodule, if possible, which is basically a re-implementation of the form interface module, but based on the same generic foundation as the rest interface module.registerFormInterfacewill get deprecated and removed at some point (not in the near future, though).However, the new module doesn't yet have all the features available. Most notably,
structtype parameters are not yet properly projected as form fields. I'll add some missing functionality and some examples in the coming days, when I port one of my projects to use it.
- Does the registerFormInterface makes it so that if I want todo a GET or a POST, I have to do something like
class app{void getAccount(...){res.render!("account.dt", req);}}and access it by doing http://example.com/account ? I mean does it turn the account.dt into a accessible page for GET or POST or am I missing something?That's right. The
vibe.web.webmodule would just add a route for GET (according to the method prefix), while theregisterFormInterfacewould accept both, GET and POST.
- Is there a performance difference when using registerFormInterface compare do just registering each url by doing
auto router = new URLRouter; router.get("/account",&account);?No, they should be more or less exactly the same.
- How customizible is the registerFormInterface other than what the examples show? Is there a easier way than using registerFormInterface possibly with user defined annotations to define the url, http method, before the function?
vibe.web.websupports this using@methodand@pathannotations (see the documentation ofvibe.web.restfor some examples). It also has some additional features, such as defining anInputStreamparameter that gets the raw request body, returning anInputStreamthat is used to source the response body, and support for session local variables. There is also a little example project, which shows the basic usage.Thank you and sorry if Im not clear. I am typing this late at night because I am still porting more of my code from node.js to vibe.d.
That noble goal definitely excuses everything ;) Let me know if anything is missing.
Hello,
Thank you for your reply. I am looking through the example, and would like to know if theres a way to accept something like /example/:id ? Do I use "HTTPServerResponse res" to fetch the params from the url along with any other parameters?