From 2beb5c8206cf33f04ef778ebc67839c1bd71add8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 18 Apr 2011 13:24:27 +0200 Subject: Move the dispatcher related types into cowboy_dispatcher. --- src/cowboy_dispatcher.erl | 9 +++++++++ src/cowboy_http_protocol.erl | 2 +- src/cowboy_http_req.erl | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cowboy_dispatcher.erl b/src/cowboy_dispatcher.erl index 46cf717..e4e5b78 100644 --- a/src/cowboy_dispatcher.erl +++ b/src/cowboy_dispatcher.erl @@ -15,6 +15,15 @@ -module(cowboy_dispatcher). -export([split_host/1, split_path/1, match/3]). %% API. +-type bindings() :: list({Key::atom(), Value::string()}). +-type path_tokens() :: list(nonempty_string()). +-type match_rule() :: '_' | '*' | list(string() | '_' | atom()). +-type dispatch_rule() :: {Host::match_rule(), list({Path::match_rule(), + Handler::module(), Opts::term()})}. +-type dispatch_rules() :: list(dispatch_rule()). + +-export_type([bindings/0, path_tokens/0, dispatch_rules/0]). + -include("include/types.hrl"). -include_lib("eunit/include/eunit.hrl"). diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index 402224d..5e9e636 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -22,7 +22,7 @@ -record(state, { socket :: inet:socket(), transport :: module(), - dispatch :: dispatch_rules(), + dispatch :: cowboy_dispatcher:dispatch_rules(), handler :: {Handler::module(), Opts::term()}, req_empty_lines = 0 :: integer(), max_empty_lines :: integer(), diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index ba37fba..f8b54e4 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -55,7 +55,8 @@ peer(Req=#http_req{socket=Socket, transport=Transport, peer=undefined}) -> peer(Req) -> {Req#http_req.peer, Req}. --spec host(Req::#http_req{}) -> {Host::path_tokens(), Req::#http_req{}}. +-spec host(Req::#http_req{}) + -> {Host::cowboy_dispatcher:path_tokens(), Req::#http_req{}}. host(Req) -> {Req#http_req.host, Req}. @@ -63,7 +64,8 @@ host(Req) -> raw_host(Req) -> {Req#http_req.raw_host, Req}. --spec path(Req::#http_req{}) -> {Path::path_tokens(), Req::#http_req{}}. +-spec path(Req::#http_req{}) + -> {Path::cowboy_dispatcher:path_tokens(), Req::#http_req{}}. path(Req) -> {Req#http_req.path, Req}. -- cgit v1.2.3