mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Improve typespecs
This commit is contained in:
parent
f3c5881dd4
commit
76d6ed83ce
2 changed files with 7 additions and 5 deletions
|
@ -222,7 +222,8 @@ headers(Req) ->
|
|||
%% returned is used as a return value.
|
||||
%% @see parse_header/3
|
||||
-spec parse_header(cowboy_http:header(), #http_req{})
|
||||
-> {any(), #http_req{}} | {error, badarg}.
|
||||
-> {any(), #http_req{}} | {undefined, binary(), #http_req{}}
|
||||
| {error, badarg}.
|
||||
parse_header(Name, Req=#http_req{p_headers=PHeaders}) ->
|
||||
case lists:keyfind(Name, 1, PHeaders) of
|
||||
false -> parse_header(Name, Req, parse_header_default(Name));
|
||||
|
@ -239,7 +240,8 @@ parse_header_default(_Name) -> undefined.
|
|||
%%
|
||||
%% When the header is unknown, the value is returned directly without parsing.
|
||||
-spec parse_header(cowboy_http:header(), #http_req{}, any())
|
||||
-> {any(), #http_req{}} | {error, badarg}.
|
||||
-> {any(), #http_req{}} | {undefined, binary(), #http_req{}}
|
||||
| {error, badarg}.
|
||||
parse_header(Name, Req, Default) when Name =:= 'Accept' ->
|
||||
parse_header(Name, Req, Default,
|
||||
fun (Value) ->
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
|
||||
%% Media type.
|
||||
content_types_p = [] ::
|
||||
[{{binary(), binary(), [{binary(), binary()}]}, atom()}],
|
||||
[{binary() | {binary(), binary(), [{binary(), binary()}]}, atom()}],
|
||||
content_type_a :: undefined
|
||||
| {{binary(), binary(), [{binary(), binary()}]}, atom()},
|
||||
| {binary() | {binary(), binary(), [{binary(), binary()}]}, atom()},
|
||||
|
||||
%% Language.
|
||||
languages_p = [] :: [binary()],
|
||||
language_a :: undefined | binary(),
|
||||
|
||||
%% Charset.
|
||||
charsets_p = [] :: [binary()],
|
||||
charsets_p = [] :: [{binary(), atom()}],
|
||||
charset_a :: undefined | binary(),
|
||||
|
||||
%% Cached resource calls.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue