Oh, that was it, I should have looked to registerRestInterface then (now I see it). I'm learning a lot from your code alone.
On Thu, 21 Aug 2014 22:29:02 GMT, Sönke Ludwig wrote:
On Thu, 21 Aug 2014 22:03:58 GMT, Juanjo Álvarez wrote:
This works perfectly, thanks!
But... how does it work? I mean, how is authPred receiving the HTTPServerRequest and response parameters? I've looked at funcattr.d and I don't see how the magic is done (not that I understand much of that file yet, I'm learning the language as I go).
What basically is done is that
registerRestInterface
searches for@before
attributes and then calls the associated function with(req, res)
parameters. The code behind which this is hidden is indeed a little hardcore, even for template/CTFE code (it'screateAttributedFunction
which creates a wrapper function with the@before
parameters properly set).
vibe.web.web
handles@before
in a little more direct way and this will be changed invibe.web.rest
at some point, too (it's necessary for supporting member functions for@before
). Look forcomputeAttributedParameterCtx
invibe.web.web
to get to the place where the parameter is set.