aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_app.erl4
-rw-r--r--src/cowboy_bstr.erl8
-rw-r--r--src/cowboy_clock.erl16
-rw-r--r--src/cowboy_cookies.erl10
-rw-r--r--src/cowboy_dispatcher.erl9
-rw-r--r--src/cowboy_http.erl43
-rw-r--r--src/cowboy_http_protocol.erl11
-rw-r--r--src/cowboy_http_req.erl89
-rw-r--r--src/cowboy_http_rest.erl1
-rw-r--r--src/cowboy_http_static.erl12
-rw-r--r--src/cowboy_http_websocket.erl7
-rw-r--r--src/cowboy_multipart.erl5
-rw-r--r--src/cowboy_sup.erl7
13 files changed, 162 insertions, 60 deletions
diff --git a/src/cowboy_app.erl b/src/cowboy_app.erl
index 78c6acd..5ed1180 100644
--- a/src/cowboy_app.erl
+++ b/src/cowboy_app.erl
@@ -16,7 +16,9 @@
-module(cowboy_app).
-behaviour(application).
--export([start/2, stop/1]). %% API.
+%% API.
+-export([start/2]).
+-export([stop/1]).
-type application_start_type() :: normal
| {takeover, node()} | {failover, node()}.
diff --git a/src/cowboy_bstr.erl b/src/cowboy_bstr.erl
index 0cd8e4d..6e5b353 100644
--- a/src/cowboy_bstr.erl
+++ b/src/cowboy_bstr.erl
@@ -15,8 +15,12 @@
%% @doc Binary string manipulation.
-module(cowboy_bstr).
--export([to_lower/1]). %% Binary strings.
--export([char_to_lower/1, char_to_upper/1]). %% Characters.
+%% Binary strings.
+-export([to_lower/1]).
+
+%% Characters.
+-export([char_to_lower/1]).
+-export([char_to_upper/1]).
%% @doc Convert a binary string to lowercase.
-spec to_lower(binary()) -> binary().
diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl
index 3193b35..d8d220e 100644
--- a/src/cowboy_clock.erl
+++ b/src/cowboy_clock.erl
@@ -21,9 +21,19 @@
-module(cowboy_clock).
-behaviour(gen_server).
--export([start_link/0, stop/0, rfc1123/0, rfc2109/1]). %% API.
--export([init/1, handle_call/3, handle_cast/2,
- handle_info/2, terminate/2, code_change/3]). %% gen_server.
+%% API.
+-export([start_link/0]).
+-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, {
universaltime = undefined :: undefined | calendar:datetime(),
diff --git a/src/cowboy_cookies.erl b/src/cowboy_cookies.erl
index 5ab27e2..4accf14 100644
--- a/src/cowboy_cookies.erl
+++ b/src/cowboy_cookies.erl
@@ -17,7 +17,10 @@
-module(cowboy_cookies).
--export([parse_cookie/1, cookie/3, cookie/2]). %% API.
+%% API.
+-export([parse_cookie/1]).
+-export([cookie/3]).
+-export([cookie/2]).
%% Types.
-type kv() :: {Name::binary(), Value::binary()}.
@@ -26,7 +29,10 @@
| {local_time, calendar:datetime()}
| {domain, binary()} | {path, binary()}
| {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, $\").
diff --git a/src/cowboy_dispatcher.erl b/src/cowboy_dispatcher.erl
index 00c067c..e0f121e 100644
--- a/src/cowboy_dispatcher.erl
+++ b/src/cowboy_dispatcher.erl
@@ -16,7 +16,10 @@
%% @doc Dispatch requests according to a hostname and path.
-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 tokens() :: list(binary()).
@@ -25,7 +28,9 @@
-type dispatch_rule() :: {Host::match_rule(), Path::dispatch_path()}.
-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").
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 5814641..7ad3d2f 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -17,18 +17,38 @@
-module(cowboy_http).
%% Parsing.
--export([list/2, nonempty_list/2, content_type/1, media_range/2, conneg/2,
- language_range/2, entity_tag_match/1, expectation/2, params/2,
- http_date/1, rfc1123_date/1, rfc850_date/1, asctime_date/1,
- whitespace/2, digits/1, token/2, token_ci/2, quoted_string/2]).
+-export([list/2]).
+-export([nonempty_list/2]).
+-export([content_type/1]).
+-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.
--export([te_chunked/2, te_identity/2, ce_identity/1]).
+-export([te_chunked/2]).
+-export([te_identity/2]).
+-export([ce_identity/1]).
%% Interpretation.
--export([connection_to_atom/1, version_to_binary/1,
- urldecode/1, urldecode/2, urlencode/1,
- urlencode/2, x_www_form_urlencoded/2]).
+-export([connection_to_atom/1]).
+-export([version_to_binary/1]).
+-export([urldecode/1]).
+-export([urldecode/2]).
+-export([urlencode/1]).
+-export([urlencode/2]).
+-export([x_www_form_urlencoded/2]).
-type method() :: 'OPTIONS' | 'GET' | 'HEAD'
| 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary().
@@ -53,7 +73,12 @@
-type headers() :: [{header(), iodata()}].
-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").
diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl
index d65127d..5ef76be 100644
--- a/src/cowboy_http_protocol.erl
+++ b/src/cowboy_http_protocol.erl
@@ -34,8 +34,13 @@
%% @see cowboy_http_handler
-module(cowboy_http_protocol).
--export([start_link/4]). %% API.
--export([init/4, parse_request/1, handler_loop/3]). %% FSM.
+%% API.
+-export([start_link/4]).
+
+%% Internal.
+-export([init/4]).
+-export([parse_request/1]).
+-export([handler_loop/3]).
-include("http.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]),
{ok, Pid}.
-%% FSM.
+%% Internal.
%% @private
-spec init(pid(), inet:socket(), module(), any()) -> ok.
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 9f3bf2e..985485a 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -21,35 +21,66 @@
%% some lazy evaluation and cache results where possible.
-module(cowboy_http_req).
--export([
- method/1, version/1, peer/1, peer_addr/1,
- host/1, host_info/1, raw_host/1, port/1,
- path/1, path_info/1, raw_path/1,
- qs_val/2, qs_val/3, qs_vals/1, raw_qs/1,
- binding/2, binding/3, bindings/1,
- header/2, header/3, headers/1,
- parse_header/2, parse_header/3,
- cookie/2, cookie/3, cookies/1,
- meta/2, meta/3
-]). %% Request API.
-
--export([
- has_body/1, body_length/1, init_stream/4, stream_body/1,
- skip_body/1, body/1, body/2, body_qs/1,
- multipart_data/1, multipart_skip/1
-]). %% Request Body API.
-
--export([
- set_resp_cookie/4, set_resp_header/3, set_resp_body/2,
- set_resp_body_fun/3, has_resp_header/2, has_resp_body/1,
- reply/2, reply/3, reply/4,
- chunked_reply/2, chunked_reply/3, chunk/2,
- upgrade_reply/3
-]). %% Response API.
-
--export([
- compact/1, transport/1
-]). %% Misc API.
+%% Request API.
+-export([method/1]).
+-export([version/1]).
+-export([peer/1]).
+-export([peer_addr/1]).
+-export([host/1]).
+-export([host_info/1]).
+-export([raw_host/1]).
+-export([port/1]).
+-export([path/1]).
+-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]).
+
+%% Request body API.
+-export([has_body/1]).
+-export([body_length/1]).
+-export([init_stream/4]).
+-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]).
+
+%% Response API.
+-export([set_resp_cookie/4]).
+-export([set_resp_header/3]).
+-export([set_resp_body/2]).
+-export([set_resp_body_fun/3]).
+-export([has_resp_header/2]).
+-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]).
+
+%% Misc API.
+-export([compact/1]).
+-export([transport/1]).
-include("http.hrl").
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl
index f58d0ee..1f83d13 100644
--- a/src/cowboy_http_rest.erl
+++ b/src/cowboy_http_rest.erl
@@ -19,6 +19,7 @@
%% documentation available at http://wiki.basho.com/Webmachine.html
%% at the time of writing.
-module(cowboy_http_rest).
+
-export([upgrade/4]).
-record(state, {
diff --git a/src/cowboy_http_static.erl b/src/cowboy_http_static.erl
index 1eb375b..1513eea 100644
--- a/src/cowboy_http_static.erl
+++ b/src/cowboy_http_static.erl
@@ -177,9 +177,15 @@
-export([init/3]).
%% cowboy_http_rest callbacks
--export([rest_init/2, allowed_methods/2, malformed_request/2,
- resource_exists/2, forbidden/2, last_modified/2, generate_etag/2,
- content_types_provided/2, file_contents/2]).
+-export([rest_init/2]).
+-export([allowed_methods/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
-export([path_to_mimetypes/2]).
diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl
index de8b2ae..0e1ecfc 100644
--- a/src/cowboy_http_websocket.erl
+++ b/src/cowboy_http_websocket.erl
@@ -19,8 +19,11 @@
%% is no need for concern as crypto is already included.
-module(cowboy_http_websocket).
--export([upgrade/4]). %% API.
--export([handler_loop/4]). %% Internal.
+%% API.
+-export([upgrade/4]).
+
+%% Internal.
+-export([handler_loop/4]).
-include("http.hrl").
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/cowboy_multipart.erl b/src/cowboy_multipart.erl
index 2428b52..26ea84f 100644
--- a/src/cowboy_multipart.erl
+++ b/src/cowboy_multipart.erl
@@ -15,6 +15,9 @@
%% @doc Multipart parser.
-module(cowboy_multipart).
+-export([parser/1]).
+-export([content_disposition/1]).
+
-type part_parser() :: parser(more(part_result())).
-type parser(T) :: fun((binary()) -> T).
-type more(T) :: T | {more, parser(T)}.
@@ -27,8 +30,6 @@
-type end_of_part() :: {end_of_part, cont(more(part_result()))}.
-type disposition() :: {binary(), [{binary(), binary()}]}.
--export([parser/1, content_disposition/1]).
-
-include_lib("eunit/include/eunit.hrl").
%% API.
diff --git a/src/cowboy_sup.erl b/src/cowboy_sup.erl
index c0ef5e2..8ce02f0 100644
--- a/src/cowboy_sup.erl
+++ b/src/cowboy_sup.erl
@@ -16,8 +16,11 @@
-module(cowboy_sup).
-behaviour(supervisor).
--export([start_link/0]). %% API.
--export([init/1]). %% supervisor.
+%% API.
+-export([start_link/0]).
+
+%% supervisor.
+-export([init/1]).
-define(SUPERVISOR, ?MODULE).