aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-05-16 17:56:45 +0200
committerLoïc Hoguin <[email protected]>2013-05-16 17:56:45 +0200
commit6d1344319a208412afa3d32f98d1b9043ff90eb7 (patch)
tree1bff5ba801a9466fee239689676c46724c697d19 /src/cowboy_protocol.erl
parent2e787fed568eac202d04912422bb2bcf811f9ed1 (diff)
downloadcowboy-6d1344319a208412afa3d32f98d1b9043ff90eb7.tar.gz
cowboy-6d1344319a208412afa3d32f98d1b9043ff90eb7.tar.bz2
cowboy-6d1344319a208412afa3d32f98d1b9043ff90eb7.zip
Add cowboy_protocol:opts() type
Should improve the detection of wrong protocol options.
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r--src/cowboy_protocol.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index 4874e9a..8a0ff17 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -56,6 +56,20 @@
-export([parse_request/3]).
-export([resume/6]).
+-type opts() :: [{compress, boolean()}
+ | {env, cowboy_middleware:env()}
+ | {max_empty_lines, non_neg_integer()}
+ | {max_header_name_length, non_neg_integer()}
+ | {max_header_value_length, non_neg_integer()}
+ | {max_headers, non_neg_integer()}
+ | {max_keepalive, non_neg_integer()}
+ | {max_request_line_length, non_neg_integer()}
+ | {middlewares, [module()]}
+ | {onrequest, cowboy:onrequest_fun()}
+ | {onresponse, cowboy:onresponse_fun()}
+ | {timeout, timeout()}].
+-export_type([opts/0]).
+
-record(state, {
socket :: inet:socket(),
transport :: module(),
@@ -78,7 +92,7 @@
%% API.
%% @doc Start an HTTP protocol process.
--spec start_link(any(), inet:socket(), module(), any()) -> {ok, pid()}.
+-spec start_link(any(), inet:socket(), module(), opts()) -> {ok, pid()}.
start_link(Ref, Socket, Transport, Opts) ->
Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]),
{ok, Pid}.
@@ -94,7 +108,7 @@ get_value(Key, Opts, Default) ->
end.
%% @private
--spec init(any(), inet:socket(), module(), any()) -> ok.
+-spec init(any(), inet:socket(), module(), opts()) -> ok.
init(Ref, Socket, Transport, Opts) ->
Compress = get_value(compress, Opts, false),
MaxEmptyLines = get_value(max_empty_lines, Opts, 5),