method(Req :: cowboy_req:req()) -> Method :: binary()
cowboy_req:method - HTTP method
method(Req :: cowboy_req:req()) -> Method :: binary()
Return the request's HTTP method.
The method can also be obtained using pattern matching:
#{method := Method} = Req.
The Req object.
The request's HTTP method is returned as a binary string. While methods are case sensitive, standard methods are always uppercase.
<<"GET">> = cowboy_req:method(Req).
init(Req, State) -> case lists:member(cowboy_req:method(Req), [<<"GET">>, <<"POST">>]) of true -> handle(Req, State); false -> method_not_allowed(Req, State) end.