[erlang-questions] Cowboy routes with Method as a condition
Loïc Hoguin
essen@REDACTED
Wed Feb 13 11:29:10 CET 2013
On 02/13/2013 11:18 AM, Max Lapshin wrote:
> Ok, I hear you, but I don't understand you.
>
> It is a very strange decision for me, because I usually prefer to select
> design choices that make programming convenient for programmers.
That's an odd statement, I'm not sure why you would think that's not
what I'm doing. What I'm not doing, however, is make easy things easier
and hard things harder, like Rails does.
> Middleware is a very bad design choice, because it requires duplicating
> code between configuration of router and middleware and it will end as
> throwing away cowboy_router at all.
Router is middleware configuration so that's probably okay.
What I don't really understand is why you need this feature at all
considering you can already have a clause per method easily (which is
fairly similar to a function per method). All you have to do is:
handle(Req, State) ->
handle_method(cowboy_req:get(method, Req), Req, State).
So I'm not sure what you are expecting. If this doesn't work out then
there's plenty other solutions, but I don't know which one is best for
your case.
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the erlang-questions
mailing list