mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Have only one -export and -export_type per line
This should make easier spotting additions and removals in commits.
This commit is contained in:
parent
e4124de2c7
commit
a5e75219f0
13 changed files with 159 additions and 57 deletions
|
@ -16,7 +16,9 @@
|
||||||
-module(cowboy_app).
|
-module(cowboy_app).
|
||||||
-behaviour(application).
|
-behaviour(application).
|
||||||
|
|
||||||
-export([start/2, stop/1]). %% API.
|
%% API.
|
||||||
|
-export([start/2]).
|
||||||
|
-export([stop/1]).
|
||||||
|
|
||||||
-type application_start_type() :: normal
|
-type application_start_type() :: normal
|
||||||
| {takeover, node()} | {failover, node()}.
|
| {takeover, node()} | {failover, node()}.
|
||||||
|
|
|
@ -15,8 +15,12 @@
|
||||||
%% @doc Binary string manipulation.
|
%% @doc Binary string manipulation.
|
||||||
-module(cowboy_bstr).
|
-module(cowboy_bstr).
|
||||||
|
|
||||||
-export([to_lower/1]). %% Binary strings.
|
%% Binary strings.
|
||||||
-export([char_to_lower/1, char_to_upper/1]). %% Characters.
|
-export([to_lower/1]).
|
||||||
|
|
||||||
|
%% Characters.
|
||||||
|
-export([char_to_lower/1]).
|
||||||
|
-export([char_to_upper/1]).
|
||||||
|
|
||||||
%% @doc Convert a binary string to lowercase.
|
%% @doc Convert a binary string to lowercase.
|
||||||
-spec to_lower(binary()) -> binary().
|
-spec to_lower(binary()) -> binary().
|
||||||
|
|
|
@ -21,9 +21,19 @@
|
||||||
-module(cowboy_clock).
|
-module(cowboy_clock).
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-export([start_link/0, stop/0, rfc1123/0, rfc2109/1]). %% API.
|
%% API.
|
||||||
-export([init/1, handle_call/3, handle_cast/2,
|
-export([start_link/0]).
|
||||||
handle_info/2, terminate/2, code_change/3]). %% gen_server.
|
-export([stop/0]).
|
||||||
|
-export([rfc1123/0]).
|
||||||
|
-export([rfc2109/1]).
|
||||||
|
|
||||||
|
%% gen_server.
|
||||||
|
-export([init/1]).
|
||||||
|
-export([handle_call/3]).
|
||||||
|
-export([handle_cast/2]).
|
||||||
|
-export([handle_info/2]).
|
||||||
|
-export([terminate/2]).
|
||||||
|
-export([code_change/3]).
|
||||||
|
|
||||||
-record(state, {
|
-record(state, {
|
||||||
universaltime = undefined :: undefined | calendar:datetime(),
|
universaltime = undefined :: undefined | calendar:datetime(),
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
|
|
||||||
-module(cowboy_cookies).
|
-module(cowboy_cookies).
|
||||||
|
|
||||||
-export([parse_cookie/1, cookie/3, cookie/2]). %% API.
|
%% API.
|
||||||
|
-export([parse_cookie/1]).
|
||||||
|
-export([cookie/3]).
|
||||||
|
-export([cookie/2]).
|
||||||
|
|
||||||
%% Types.
|
%% Types.
|
||||||
-type kv() :: {Name::binary(), Value::binary()}.
|
-type kv() :: {Name::binary(), Value::binary()}.
|
||||||
|
@ -26,7 +29,10 @@
|
||||||
| {local_time, calendar:datetime()}
|
| {local_time, calendar:datetime()}
|
||||||
| {domain, binary()} | {path, binary()}
|
| {domain, binary()} | {path, binary()}
|
||||||
| {secure, true | false} | {http_only, true | false}.
|
| {secure, true | false} | {http_only, true | false}.
|
||||||
-export_type([kv/0, kvlist/0, cookie_option/0]).
|
|
||||||
|
-export_type([kv/0]).
|
||||||
|
-export_type([kvlist/0]).
|
||||||
|
-export_type([cookie_option/0]).
|
||||||
|
|
||||||
-define(QUOTE, $\").
|
-define(QUOTE, $\").
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
%% @doc Dispatch requests according to a hostname and path.
|
%% @doc Dispatch requests according to a hostname and path.
|
||||||
-module(cowboy_dispatcher).
|
-module(cowboy_dispatcher).
|
||||||
|
|
||||||
-export([split_host/1, split_path/2, match/3]). %% API.
|
%% API.
|
||||||
|
-export([split_host/1]).
|
||||||
|
-export([split_path/2]).
|
||||||
|
-export([match/3]).
|
||||||
|
|
||||||
-type bindings() :: list({atom(), binary()}).
|
-type bindings() :: list({atom(), binary()}).
|
||||||
-type tokens() :: list(binary()).
|
-type tokens() :: list(binary()).
|
||||||
|
@ -25,7 +28,9 @@
|
||||||
-type dispatch_rule() :: {Host::match_rule(), Path::dispatch_path()}.
|
-type dispatch_rule() :: {Host::match_rule(), Path::dispatch_path()}.
|
||||||
-type dispatch_rules() :: list(dispatch_rule()).
|
-type dispatch_rules() :: list(dispatch_rule()).
|
||||||
|
|
||||||
-export_type([bindings/0, tokens/0, dispatch_rules/0]).
|
-export_type([bindings/0]).
|
||||||
|
-export_type([tokens/0]).
|
||||||
|
-export_type([dispatch_rules/0]).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,38 @@
|
||||||
-module(cowboy_http).
|
-module(cowboy_http).
|
||||||
|
|
||||||
%% Parsing.
|
%% Parsing.
|
||||||
-export([list/2, nonempty_list/2, content_type/1, media_range/2, conneg/2,
|
-export([list/2]).
|
||||||
language_range/2, entity_tag_match/1, expectation/2, params/2,
|
-export([nonempty_list/2]).
|
||||||
http_date/1, rfc1123_date/1, rfc850_date/1, asctime_date/1,
|
-export([content_type/1]).
|
||||||
whitespace/2, digits/1, token/2, token_ci/2, quoted_string/2]).
|
-export([media_range/2]).
|
||||||
|
-export([conneg/2]).
|
||||||
|
-export([language_range/2]).
|
||||||
|
-export([entity_tag_match/1]).
|
||||||
|
-export([expectation/2]).
|
||||||
|
-export([params/2]).
|
||||||
|
-export([http_date/1]).
|
||||||
|
-export([rfc1123_date/1]).
|
||||||
|
-export([rfc850_date/1]).
|
||||||
|
-export([asctime_date/1]).
|
||||||
|
-export([whitespace/2]).
|
||||||
|
-export([digits/1]).
|
||||||
|
-export([token/2]).
|
||||||
|
-export([token_ci/2]).
|
||||||
|
-export([quoted_string/2]).
|
||||||
|
|
||||||
%% Decoding.
|
%% Decoding.
|
||||||
-export([te_chunked/2, te_identity/2, ce_identity/1]).
|
-export([te_chunked/2]).
|
||||||
|
-export([te_identity/2]).
|
||||||
|
-export([ce_identity/1]).
|
||||||
|
|
||||||
%% Interpretation.
|
%% Interpretation.
|
||||||
-export([connection_to_atom/1, version_to_binary/1,
|
-export([connection_to_atom/1]).
|
||||||
urldecode/1, urldecode/2, urlencode/1,
|
-export([version_to_binary/1]).
|
||||||
urlencode/2, x_www_form_urlencoded/2]).
|
-export([urldecode/1]).
|
||||||
|
-export([urldecode/2]).
|
||||||
|
-export([urlencode/1]).
|
||||||
|
-export([urlencode/2]).
|
||||||
|
-export([x_www_form_urlencoded/2]).
|
||||||
|
|
||||||
-type method() :: 'OPTIONS' | 'GET' | 'HEAD'
|
-type method() :: 'OPTIONS' | 'GET' | 'HEAD'
|
||||||
| 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary().
|
| 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary().
|
||||||
|
@ -53,7 +73,12 @@
|
||||||
-type headers() :: [{header(), iodata()}].
|
-type headers() :: [{header(), iodata()}].
|
||||||
-type status() :: non_neg_integer() | binary().
|
-type status() :: non_neg_integer() | binary().
|
||||||
|
|
||||||
-export_type([method/0, uri/0, version/0, header/0, headers/0, status/0]).
|
-export_type([method/0]).
|
||||||
|
-export_type([uri/0]).
|
||||||
|
-export_type([version/0]).
|
||||||
|
-export_type([header/0]).
|
||||||
|
-export_type([headers/0]).
|
||||||
|
-export_type([status/0]).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,13 @@
|
||||||
%% @see cowboy_http_handler
|
%% @see cowboy_http_handler
|
||||||
-module(cowboy_http_protocol).
|
-module(cowboy_http_protocol).
|
||||||
|
|
||||||
-export([start_link/4]). %% API.
|
%% API.
|
||||||
-export([init/4, parse_request/1, handler_loop/3]). %% FSM.
|
-export([start_link/4]).
|
||||||
|
|
||||||
|
%% Internal.
|
||||||
|
-export([init/4]).
|
||||||
|
-export([parse_request/1]).
|
||||||
|
-export([handler_loop/3]).
|
||||||
|
|
||||||
-include("http.hrl").
|
-include("http.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
@ -70,7 +75,7 @@ start_link(ListenerPid, Socket, Transport, Opts) ->
|
||||||
Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]),
|
Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]),
|
||||||
{ok, Pid}.
|
{ok, Pid}.
|
||||||
|
|
||||||
%% FSM.
|
%% Internal.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
-spec init(pid(), inet:socket(), module(), any()) -> ok.
|
-spec init(pid(), inet:socket(), module(), any()) -> ok.
|
||||||
|
|
|
@ -21,35 +21,66 @@
|
||||||
%% some lazy evaluation and cache results where possible.
|
%% some lazy evaluation and cache results where possible.
|
||||||
-module(cowboy_http_req).
|
-module(cowboy_http_req).
|
||||||
|
|
||||||
-export([
|
%% Request API.
|
||||||
method/1, version/1, peer/1, peer_addr/1,
|
-export([method/1]).
|
||||||
host/1, host_info/1, raw_host/1, port/1,
|
-export([version/1]).
|
||||||
path/1, path_info/1, raw_path/1,
|
-export([peer/1]).
|
||||||
qs_val/2, qs_val/3, qs_vals/1, raw_qs/1,
|
-export([peer_addr/1]).
|
||||||
binding/2, binding/3, bindings/1,
|
-export([host/1]).
|
||||||
header/2, header/3, headers/1,
|
-export([host_info/1]).
|
||||||
parse_header/2, parse_header/3,
|
-export([raw_host/1]).
|
||||||
cookie/2, cookie/3, cookies/1,
|
-export([port/1]).
|
||||||
meta/2, meta/3
|
-export([path/1]).
|
||||||
]). %% Request API.
|
-export([path_info/1]).
|
||||||
|
-export([raw_path/1]).
|
||||||
|
-export([qs_val/2]).
|
||||||
|
-export([qs_val/3]).
|
||||||
|
-export([qs_vals/1]).
|
||||||
|
-export([raw_qs/1]).
|
||||||
|
-export([binding/2]).
|
||||||
|
-export([binding/3]).
|
||||||
|
-export([bindings/1]).
|
||||||
|
-export([header/2]).
|
||||||
|
-export([header/3]).
|
||||||
|
-export([headers/1]).
|
||||||
|
-export([parse_header/2]).
|
||||||
|
-export([parse_header/3]).
|
||||||
|
-export([cookie/2]).
|
||||||
|
-export([cookie/3]).
|
||||||
|
-export([cookies/1]).
|
||||||
|
-export([meta/2]).
|
||||||
|
-export([meta/3]).
|
||||||
|
|
||||||
-export([
|
%% Request body API.
|
||||||
has_body/1, body_length/1, init_stream/4, stream_body/1,
|
-export([has_body/1]).
|
||||||
skip_body/1, body/1, body/2, body_qs/1,
|
-export([body_length/1]).
|
||||||
multipart_data/1, multipart_skip/1
|
-export([init_stream/4]).
|
||||||
]). %% Request Body API.
|
-export([stream_body/1]).
|
||||||
|
-export([skip_body/1]).
|
||||||
|
-export([body/1]).
|
||||||
|
-export([body/2]).
|
||||||
|
-export([body_qs/1]).
|
||||||
|
-export([multipart_data/1]).
|
||||||
|
-export([multipart_skip/1]).
|
||||||
|
|
||||||
-export([
|
%% Response API.
|
||||||
set_resp_cookie/4, set_resp_header/3, set_resp_body/2,
|
-export([set_resp_cookie/4]).
|
||||||
set_resp_body_fun/3, has_resp_header/2, has_resp_body/1,
|
-export([set_resp_header/3]).
|
||||||
reply/2, reply/3, reply/4,
|
-export([set_resp_body/2]).
|
||||||
chunked_reply/2, chunked_reply/3, chunk/2,
|
-export([set_resp_body_fun/3]).
|
||||||
upgrade_reply/3
|
-export([has_resp_header/2]).
|
||||||
]). %% Response API.
|
-export([has_resp_body/1]).
|
||||||
|
-export([reply/2]).
|
||||||
|
-export([reply/3]).
|
||||||
|
-export([reply/4]).
|
||||||
|
-export([chunked_reply/2]).
|
||||||
|
-export([chunked_reply/3]).
|
||||||
|
-export([chunk/2]).
|
||||||
|
-export([upgrade_reply/3]).
|
||||||
|
|
||||||
-export([
|
%% Misc API.
|
||||||
compact/1, transport/1
|
-export([compact/1]).
|
||||||
]). %% Misc API.
|
-export([transport/1]).
|
||||||
|
|
||||||
-include("http.hrl").
|
-include("http.hrl").
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
%% documentation available at http://wiki.basho.com/Webmachine.html
|
%% documentation available at http://wiki.basho.com/Webmachine.html
|
||||||
%% at the time of writing.
|
%% at the time of writing.
|
||||||
-module(cowboy_http_rest).
|
-module(cowboy_http_rest).
|
||||||
|
|
||||||
-export([upgrade/4]).
|
-export([upgrade/4]).
|
||||||
|
|
||||||
-record(state, {
|
-record(state, {
|
||||||
|
|
|
@ -177,9 +177,15 @@
|
||||||
-export([init/3]).
|
-export([init/3]).
|
||||||
|
|
||||||
%% cowboy_http_rest callbacks
|
%% cowboy_http_rest callbacks
|
||||||
-export([rest_init/2, allowed_methods/2, malformed_request/2,
|
-export([rest_init/2]).
|
||||||
resource_exists/2, forbidden/2, last_modified/2, generate_etag/2,
|
-export([allowed_methods/2]).
|
||||||
content_types_provided/2, file_contents/2]).
|
-export([malformed_request/2]).
|
||||||
|
-export([resource_exists/2]).
|
||||||
|
-export([forbidden/2]).
|
||||||
|
-export([last_modified/2]).
|
||||||
|
-export([generate_etag/2]).
|
||||||
|
-export([content_types_provided/2]).
|
||||||
|
-export([file_contents/2]).
|
||||||
|
|
||||||
%% internal
|
%% internal
|
||||||
-export([path_to_mimetypes/2]).
|
-export([path_to_mimetypes/2]).
|
||||||
|
|
|
@ -19,8 +19,11 @@
|
||||||
%% is no need for concern as crypto is already included.
|
%% is no need for concern as crypto is already included.
|
||||||
-module(cowboy_http_websocket).
|
-module(cowboy_http_websocket).
|
||||||
|
|
||||||
-export([upgrade/4]). %% API.
|
%% API.
|
||||||
-export([handler_loop/4]). %% Internal.
|
-export([upgrade/4]).
|
||||||
|
|
||||||
|
%% Internal.
|
||||||
|
-export([handler_loop/4]).
|
||||||
|
|
||||||
-include("http.hrl").
|
-include("http.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
%% @doc Multipart parser.
|
%% @doc Multipart parser.
|
||||||
-module(cowboy_multipart).
|
-module(cowboy_multipart).
|
||||||
|
|
||||||
|
-export([parser/1]).
|
||||||
|
-export([content_disposition/1]).
|
||||||
|
|
||||||
-type part_parser() :: parser(more(part_result())).
|
-type part_parser() :: parser(more(part_result())).
|
||||||
-type parser(T) :: fun((binary()) -> T).
|
-type parser(T) :: fun((binary()) -> T).
|
||||||
-type more(T) :: T | {more, parser(T)}.
|
-type more(T) :: T | {more, parser(T)}.
|
||||||
|
@ -27,8 +30,6 @@
|
||||||
-type end_of_part() :: {end_of_part, cont(more(part_result()))}.
|
-type end_of_part() :: {end_of_part, cont(more(part_result()))}.
|
||||||
-type disposition() :: {binary(), [{binary(), binary()}]}.
|
-type disposition() :: {binary(), [{binary(), binary()}]}.
|
||||||
|
|
||||||
-export([parser/1, content_disposition/1]).
|
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
%% API.
|
%% API.
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
-module(cowboy_sup).
|
-module(cowboy_sup).
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
|
|
||||||
-export([start_link/0]). %% API.
|
%% API.
|
||||||
-export([init/1]). %% supervisor.
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
%% supervisor.
|
||||||
|
-export([init/1]).
|
||||||
|
|
||||||
-define(SUPERVISOR, ?MODULE).
|
-define(SUPERVISOR, ?MODULE).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue