mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Detect invalid content_types_provided return values earlier
Before this change invalid return values would be detected via unhelpful error messages such as [1] and the closing of the connection. [1] Bad value on output port 'tcp_inet'
This commit is contained in:
parent
fbd680f0f6
commit
72b57a846d
3 changed files with 25 additions and 4 deletions
|
@ -11,9 +11,14 @@
|
|||
init(Req, Opts) ->
|
||||
{cowboy_rest, Req, Opts}.
|
||||
|
||||
content_types_provided(Req=#{qs := <<"invalid-type">>}, State) ->
|
||||
ct_helper:ignore(cowboy_rest, normalize_content_types, 2),
|
||||
{[{{'*', '*', '*'}, get_text_plain}], Req, State};
|
||||
content_types_provided(Req=#{qs := <<"wildcard-param">>}, State) ->
|
||||
{[{{<<"text">>, <<"plain">>, '*'}, get_text_plain}], Req, State}.
|
||||
|
||||
get_text_plain(Req=#{qs := <<"invalid-type">>}, State) ->
|
||||
{<<"invalid-type">>, Req, State};
|
||||
get_text_plain(Req=#{qs := <<"wildcard-param">>}, State) ->
|
||||
{_, _, Param} = maps:get(media_type, Req),
|
||||
Body = if
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue