Skip to content

Commit

Permalink
Add types for onrequest and onresponse funs
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Sep 17, 2012
1 parent 9090cd9 commit c2be7c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/cowboy_protocol.erl
Expand Up @@ -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(),
Expand Down
3 changes: 1 addition & 2 deletions src/cowboy_req.erl
Expand Up @@ -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}
}).

Expand Down

0 comments on commit c2be7c1

Please sign in to comment.