Add your stream handler to the list of stream handlers in the protocol options:
{ok, Pid} = cowboy:start_clear(ListenerName,
[{port, Port}],
#{
env => #{dispatch => Dispatch},
stream_handlers => [my_stream_h, cowboy_compress_h, cowboy_stream_h]
}
),
A stream handler
- should implement the behavior
cowboy_stream
. - inserts itself into the request/response stack and can modify both incoming requests and outgoing repsonses
Was trying to convert this to elixir and failed miserably, can you take a look at this: