[erlang-questions] trying to learn cowboy

John Doe donpedrothird@REDACTED
Mon Jun 29 14:46:19 CEST 2015


Loïc, while you are there, is it possible to make a route which accepts
unlimited number of slashes in PathMatch and get path with slashes as a
named parameter?
Like, the if the first segment is /a/ get allthe next segments as a single
parameter, be it /a/b/ or /a/c/d/e/f/ ?

2015-06-28 22:07 GMT+03:00 Loïc Hoguin <essen@REDACTED>:

>
>
> On 06/28/2015 08:55 PM, Ben Hsu wrote:
>
>> 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', _} ->
>>
>
> {<<"GET">>, _}
>
> Not sure where you saw any '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}.
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
> --
> Loïc Hoguin
> http://ninenines.eu
> Author of The Erlanger Playbook,
> A book about software development using Erlang
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150629/dfb876e0/attachment.htm>


More information about the erlang-questions mailing list