vibe.d get parameters

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Thu May 5 19:53:20 PDT 2016


There are two problems here.

1) Your problem comes from the fact that `id` parameter name has 
been special cased since early vibe.d versions to mean URL 
parameter. If you enable `setLogLevel(LogLevel.debug_);` in the 
very beginning of module constructor, you will see this trace:

REST route: GET /:id/something/ []
add route GET /:id/something/

It basically automatically rewrites route to prepend :id and 
treats `string id` as if it was `string _id`.

2) Changing the name of string argument to `xxx` still doesn't 
work and now prints this in debug trace:

REST route: GET /something/ ["xxx"]
add route GET /something/

Note the / in the end. Vibe.d does exact matching of slashes in 
the version I have checked so you would have to request 
http://127.0.0.1:8081/something/?xxx=a to get response.

So to make URL you want to work you'd need to do something like 
this:

```
interface Api
{
     @method(HTTPMethod.GET) @path("/something")
     string getSomething(string xxx);
}
```


More information about the Digitalmars-d mailing list