[erlang-questions] Cowboy routes with Method as a condition

Olav Frengstad olav@REDACTED
Wed Feb 13 09:39:37 CET 2013

I use a small wrapper over cowboy_http_hander that let's me bind a
method to a function call.

method_handlers(Req, State) ->
    [{<<"GET">>, read}, {<<"POST">>, update}, Req, State].

read(Req, State) ->
    {Req, State}.

update(Req, State) ->
    {Req, State}.

The easiest making handle/2 call handle_method(Method, Req, State) or similar.

If you want something pluggable you can look at https://github.com/lafka/tavern


2013/2/11 Max Lapshin <max.lapshin@REDACTED>:
> cowboy_rest is incredibly hard to use because there is even no full list of
> callbacks. Webmachine diagram is good, but it lacks name of callbacks.
> I understand that it is hard to document it, but I can't help you with it
> because I don't understand this code in depth.
> I want to put Amazon S3 API in routes and it looks like rest is a bad idea.
> I've ended with catch-all route and manual routing in init/3 handler
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Med Vennlig Hilsen
Olav Frengstad

Systemutvikler // FWT
+47 920 42 090

More information about the erlang-questions mailing list