0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

Add types for onrequest and onresponse funs

This commit is contained in:
Loïc Hoguin 2012-09-17 13:25:46 +02:00
parent 9090cd9765
commit c2be7c1920
2 changed files with 10 additions and 5 deletions

View file

@ -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(),

View file

@ -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}
}).