toppage_handler.erl 373 B

123456789101112131415
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. %% @doc Chunked hello world handler.
  3. -module(toppage_handler).
  4. -export([init/2]).
  5. init(Req, Opts) ->
  6. cowboy_req:chunked_reply(200, Req),
  7. cowboy_req:chunk("Hello\r\n", Req),
  8. timer:sleep(1000),
  9. cowboy_req:chunk("World\r\n", Req),
  10. timer:sleep(1000),
  11. cowboy_req:chunk("Chunked!\r\n", Req),
  12. {ok, Req, Opts}.