2012-05-02 20:27:44 +02:00
|
|
|
%% Feel free to use, reuse and abuse the code in this file.
|
|
|
|
|
|
|
|
-module(http_handler_loop_timeout).
|
2012-08-27 12:46:42 +02:00
|
|
|
-behaviour(cowboy_loop_handler).
|
2013-01-22 02:34:18 +01:00
|
|
|
-export([init/3, info/3, terminate/3]).
|
2012-05-02 20:27:44 +02:00
|
|
|
|
|
|
|
init({_, http}, Req, _) ->
|
|
|
|
erlang:send_after(1000, self(), error_timeout),
|
|
|
|
{loop, Req, undefined, 500, hibernate}.
|
|
|
|
|
|
|
|
info(error_timeout, Req, State) ->
|
2012-08-27 13:28:57 +02:00
|
|
|
{ok, Req2} = cowboy_req:reply(500, Req),
|
2012-05-02 20:27:44 +02:00
|
|
|
{ok, Req2, State}.
|
|
|
|
|
2013-01-22 02:34:18 +01:00
|
|
|
terminate({normal, timeout}, _, _) ->
|
2012-05-02 20:27:44 +02:00
|
|
|
ok.
|