http_handler_init_shutdown.erl 487 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/2]).
  5. init({_Transport, http}, Req, _Opts) ->
  6. Req2 = cowboy_http_req:reply(<<"666 Init Shutdown Testing">>,
  7. [{'Connection', <<"close">>}], [], Req),
  8. {shutdown, Req2, undefined}.
  9. handle(Req, State) ->
  10. Req2 = cowboy_http_req:reply(200, [], "Hello world!", Req),
  11. {ok, Req2, State}.
  12. terminate(_Req, _State) ->
  13. ok.