i need help on how to disable HTTP methods on my cowboy server.
Tried to search on the internet but eneded up with no solutions
i need help on how to disable HTTP methods on my cowboy server.
Tried to search on the internet but eneded up with no solutions
The documentation for method gives this example:
init(Req, State) ->
case lists:member(cowboy_req:method(Req), [<<"GET">>, <<"POST">>]) of
true -> handle(Req, State);
false -> method_not_allowed(Req, State)
end.
You can easily adapt that to be a blacklist instead of a whitelist. For example, to ban OPTIONS and TRACE, you'd do this:
init(Req, State) ->
case lists:member(cowboy_req:method(Req), [<<"OPTIONS">>, <<"TRACE">>]) of
false -> handle(Req, State);
true -> method_not_allowed(Req, State)
end.