http_handler_loop_timeout.erl 383 B

123456789101112131415
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_handler_loop_timeout).
  3. -export([init/3, info/3, terminate/2]).
  4. init({_, http}, Req, _) ->
  5. erlang:send_after(1000, self(), error_timeout),
  6. {loop, Req, undefined, 500, hibernate}.
  7. info(error_timeout, Req, State) ->
  8. {ok, Req2} = cowboy_http_req:reply(500, Req),
  9. {ok, Req2, State}.
  10. terminate(_, _) ->
  11. ok.