mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 20:50:24 +00:00
Improve the return value for cowboy_http_rest:upgrade/4
This commit is contained in:
parent
7482c0de75
commit
3078e94db6
1 changed files with 3 additions and 2 deletions
|
@ -53,7 +53,8 @@
|
|||
%% You do not need to call this function manually. To upgrade to the REST
|
||||
%% protocol, you simply need to return <em>{upgrade, protocol, {@module}}</em>
|
||||
%% in your <em>cowboy_http_handler:init/3</em> handler function.
|
||||
-spec upgrade(pid(), module(), any(), #http_req{}) -> {ok, #http_req{}}.
|
||||
-spec upgrade(pid(), module(), any(), #http_req{})
|
||||
-> {ok, #http_req{}} | close.
|
||||
upgrade(_ListenerPid, Handler, Opts, Req) ->
|
||||
try
|
||||
case erlang:function_exported(Handler, rest_init, 2) of
|
||||
|
@ -73,7 +74,7 @@ upgrade(_ListenerPid, Handler, Opts, Req) ->
|
|||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||
[Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()]),
|
||||
{ok, _Req2} = cowboy_http_req:reply(500, Req),
|
||||
ok
|
||||
close
|
||||
end.
|
||||
|
||||
service_available(Req, State) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue