|
@@ -53,7 +53,8 @@
|
|
%% You do not need to call this function manually. To upgrade to the REST
|
|
%% 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>
|
|
%% protocol, you simply need to return <em>{upgrade, protocol, {@module}}</em>
|
|
%% in your <em>cowboy_http_handler:init/3</em> handler function.
|
|
%% 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) ->
|
|
upgrade(_ListenerPid, Handler, Opts, Req) ->
|
|
try
|
|
try
|
|
case erlang:function_exported(Handler, rest_init, 2) of
|
|
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",
|
|
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
|
[Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()]),
|
|
[Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()]),
|
|
{ok, _Req2} = cowboy_http_req:reply(500, Req),
|
|
{ok, _Req2} = cowboy_http_req:reply(500, Req),
|
|
- ok
|
|
|
|
|
|
+ close
|
|
end.
|
|
end.
|
|
|
|
|
|
service_available(Req, State) ->
|
|
service_available(Req, State) ->
|