http_loop_timeout.erl 422 B

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