On Sun, 19 Oct 2014 13:06:08 GMT, Arjan wrote:
Hello,
What is the recommanded way to access and set http headers in a rest api impl?
Using @before / @after or add an 'any' tot the router?
Same question for accessing uri query string part.Thanks.
Arjan
It always depends on the use case, but both ways can make sense (using the router when all routes need to do the same thing and using an attribute when only some of the routes are affected). You can also make an enum
out of @before
/@after
annotations, so that you have more compact and readable attributes (e.g. @authenticated
instead of @before!performAuth("_authUserInfo")
: enum authenticated = before!performAuth("_authUserInfo")
.
There is also currently an open pull request (which I still need to review) that will add @fromQuery
and @fromHeader
attributes.