From 0f8452cafaa27aeffb103019564c086eacfd34f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Jan 2017 14:22:43 +0100 Subject: Add support for multiple stream handlers The stream handlers can be specified using the protocol option 'stream_handlers'. It defaults to [cowboy_stream_h]. The cowboy_stream_h module currently does not forward the calls to further stream handlers. It feels like an edge case; usually we'd want to put our own handlers between the protocol code and the request process. I am therefore going to focus on other things for now. The various types and specifications for stream handlers have been updated and the cowboy_stream module can now be safely used as a behavior. The interface might change a little more, though. This commit does not include tests or documentation. They will follow separately. --- src/cowboy_clear.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/cowboy_clear.erl') diff --git a/src/cowboy_clear.erl b/src/cowboy_clear.erl index cd8b2ca..7ff5d8b 100644 --- a/src/cowboy_clear.erl +++ b/src/cowboy_clear.erl @@ -40,9 +40,8 @@ init(Parent, Ref, Socket, Transport, Opts) -> init(Parent, Ref, Socket, Transport, Opts, cowboy_http). init(Parent, Ref, Socket, Transport, Opts, Protocol) -> - {Handler, Type} = maps:get(stream_handler, Opts, {cowboy_stream_h, supervisor}), - _ = case Type of + _ = case maps:get(connection_type, Opts, supervisor) of worker -> ok; supervisor -> process_flag(trap_exit, true) end, - Protocol:init(Parent, Ref, Socket, Transport, Opts, Handler). + Protocol:init(Parent, Ref, Socket, Transport, Opts). -- cgit v1.2.3