aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-17 13:25:46 +0200
committerLoïc Hoguin <[email protected]>2012-09-17 13:57:29 +0200
commitc2be7c19204174d16836e6fced3c876ace6860a1 (patch)
tree292c05f3375260ad8561a725033b3385a3b39abb
parent9090cd976553a8527d59e2638793011a3604e262 (diff)
downloadcowboy-c2be7c19204174d16836e6fced3c876ace6860a1.tar.gz
cowboy-c2be7c19204174d16836e6fced3c876ace6860a1.tar.bz2
cowboy-c2be7c19204174d16836e6fced3c876ace6860a1.zip
Add types for onrequest and onresponse funs
-rw-r--r--src/cowboy_protocol.erl12
-rw-r--r--src/cowboy_req.erl3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index f4cbed5..2e734c5 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -46,15 +46,21 @@
-include_lib("eunit/include/eunit.hrl").
-endif.
+-type onrequest_fun() :: fun((Req) -> Req).
+-type onresponse_fun() ::
+ fun((cowboy_http:status(), cowboy_http:headers(), Req) -> Req).
+
+-export_type([onrequest_fun/0]).
+-export_type([onresponse_fun/0]).
+
-record(state, {
listener :: pid(),
socket :: inet:socket(),
transport :: module(),
dispatch :: cowboy_dispatcher:dispatch_rules(),
handler :: {module(), any()},
- onrequest :: undefined | fun((cowboy_req:req()) -> cowboy_req:req()),
- onresponse = undefined :: undefined | fun((cowboy_http:status(),
- cowboy_http:headers(), cowboy_req:req()) -> cowboy_req:req()),
+ onrequest :: undefined | onrequest_fun(),
+ onresponse = undefined :: undefined | onresponse_fun(),
urldecode :: {fun((binary(), T) -> binary()), T},
req_empty_lines = 0 :: integer(),
max_empty_lines :: integer(),
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index d0aa3c6..f8e0b6a 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -158,8 +158,7 @@
| {non_neg_integer(), fun(() -> {sent, non_neg_integer()})},
%% Functions.
- onresponse = undefined :: undefined | fun((cowboy_http:status(),
- cowboy_http:headers(), Req) -> Req),
+ onresponse = undefined :: undefined | cowboy_protocol:onresponse_fun(),
urldecode :: {fun((binary(), T) -> binary()), T}
}).