Custom dispatch options in Phoenix using cowboy 2.x

I have found instructions for adding custom dispatch handlers into a phoenix application.

https://hexdocs.pm/phoenix/Phoenix.Endpoint.CowboyHandler.html#module-custom-dispatch-options

Now that phoenix supports cowboy 2.0 is there a way to do this for cowboy 2.0. Specifically I want to add some custom handlers that are cowboy stream handlers.

https://ninenines.eu/docs/en/cowboy/2.0/guide/streams/

This might be a question more for the phoenix team. @chrismccord or perhaps @Gazler?

2 Likes

You can pass stream_handlers as an option. Dispatch works the same way as it did with Cowboy 1:

Here’s a test that uses stream_handlers https://github.com/elixir-plug/plug/blob/41fbbc30953d7a397fbdf661a07c9df526e9984c/test/plug/adapters/cowboy2_test.exs#L125