http_errors.erl 500 B

1234567891011121314151617
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(http_errors).
  3. -export([init/2]).
  4. init(Req, _Opts) ->
  5. #{'case' := Case} = cowboy_req:match_qs(['case'], Req),
  6. case_init(Case, Req).
  7. case_init(<<"init_before_reply">> = Case, _Req) ->
  8. cowboy_error_h:ignore(?MODULE, case_init, 2),
  9. error(Case);
  10. case_init(<<"init_after_reply">> = Case, Req) ->
  11. cowboy_error_h:ignore(?MODULE, case_init, 2),
  12. _ = cowboy_req:reply(200, [], "http_handler_crashes", Req),
  13. error(Case).