[erlang-questions] Thoughts on EHE - the PHP killer

Steve Vinoski vinoski@REDACTED
Mon Feb 20 13:23:23 CET 2012


On Sun, Feb 19, 2012 at 9:17 AM, Tim Watson <watson.timothy@REDACTED> wrote:
> Next question I have is, how hard would it be to do something like a
> servlet filter in YAWS? I could do this quite well using annotations -
> that's how ErlangWeb does it, albeit with macros instead - but is that
> the best way? It would look something like this (and is quite easy to
> implement using annotations):
>
> -secured({auth_provider, oauth}).
> -controller({"/accounts/{account_type}/{account_number}/", 'GET'}).
> get_account(AccountType, AccountNum, YawsArg) -> ....
>
>
> Is there something else in YAWS like appmod that'll do a filter chain,
> or am I better off using annotations?

There's really nothing like servlet filters. I guess the closest thing
-- admittedly not very close, though -- is the ability to add a
rewriter, which sits in the dispatch path, takes in the #arg, and can
produce a modified one if it wants to.

Just off the top of my head, it seems like one could do something like
servlet filters with an appmod, I think. Register it on /, and give it
it's own dispatching configuration and allow plug-ins to register into
its request-reply path. It could then receive each request, arrange
the ultimate dispatch target (an appmod, a .yaws page, even a file) at
the end of plug-in chain, dispatch the #arg into the chain, and then
deliver the eventual reply back into Yaws. No doubt this would be
easier if it were built into Yaws, though, since reusing the existing
dispatch logic would be easier than writing your own.

--steve



More information about the erlang-questions mailing list