[erlang-questions] trying to learn cowboy

Ben Hsu benhsu@REDACTED
Sun Jun 28 20:55:56 CEST 2015


Hello Erlangers

I am going through some basic steps learning cowboy, and I'm doing
something wrong, but I can't figure it out.

In the code below, I'm pattern matching against cowboy_req:method(Req), and
it _should_ be returning {'GET', _}, which takes me to the first branch of
the case statement. But it keeps executing the default case.

I printed out what cowboy_req:method is returning, and it looks like GET,
In the spirit of shotgun-debugging this I've tried matching against 'GET',
"GET", <<'GET'>>, and <<"GET">>, none of which work

I'm sure there is something simple I am missing here. What is it?


Thank you for your time and patience :)

handle(Req, State) ->
    Reply = case cowboy_req:method(Req) of
        {'GET', _} ->
% this is never executed when I do a curl-GET against my app
SomeMsg = "some message",
{ok, Req2} = cowboy_req:reply(200,
[{<<"content-type">>, <<"text/plain">>}],
SomeMsg,
Req),
  {ok, Req2, State};
        _ ->
% even though i am printing out what cowboy_req:method returns here and it
says GET
{FNORD, _} = cowboy_req:method(Req),
            {ok, R} = cowboy_req:reply(200, [], FNORD, Req),
            R
    end,
    {ok, Reply, State}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150628/a2319497/attachment.htm>


More information about the erlang-questions mailing list