http_handler_init_shutdown.erl 484 B

1234567891011121314151617
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_handler_init_shutdown).
  3. -behaviour(cowboy_http_handler).
  4. -export([init/3, handle/2, terminate/3]).
  5. init({_Transport, http}, Req, _Opts) ->
  6. {ok, Req2} = cowboy_req:reply(<<"666 Init Shutdown Testing">>,
  7. [{<<"connection">>, <<"close">>}], Req),
  8. {shutdown, Req2, undefined}.
  9. handle(Req, State) ->
  10. {ok, Req2} = cowboy_req:reply(200, [], "Hello world!", Req),
  11. {ok, Req2, State}.
  12. terminate(_, _, _) ->
  13. ok.