0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Rename match() into match_rule().

This commit is contained in:
Loïc Hoguin 2011-04-18 12:20:52 +02:00
parent ef2673b61e
commit 6712eaa5c8
2 changed files with 5 additions and 5 deletions

View file

@ -20,8 +20,8 @@
-type bindings() :: list({Key::atom(), Value::string()}). -type bindings() :: list({Key::atom(), Value::string()}).
-type path_tokens() :: list(nonempty_string()). -type path_tokens() :: list(nonempty_string()).
-type match() :: '_' | '*' | list(string() | '_' | atom()). -type match_rule() :: '_' | '*' | list(string() | '_' | atom()).
-type dispatch_rule() :: {Host::match(), list({Path::match(), -type dispatch_rule() :: {Host::match_rule(), list({Path::match_rule(),
Handler::module(), Opts::term()})}. Handler::module(), Opts::term()})}.
-type dispatch_rules() :: list(dispatch_rule()). -type dispatch_rules() :: list(dispatch_rule()).

View file

@ -55,7 +55,7 @@ match(Host, Path, [{HostMatch, PathMatchs}|Tail]) ->
match_path(Path, PathMatchs, HostBinds) match_path(Path, PathMatchs, HostBinds)
end. end.
-spec match_path(Path::path_tokens(), list({Path::match(), -spec match_path(Path::path_tokens(), list({Path::match_rule(),
Handler::module(), Opts::term()}), HostBinds::bindings()) Handler::module(), Opts::term()}), HostBinds::bindings())
-> {ok, Handler::module(), Opts::term(), Binds::bindings()} -> {ok, Handler::module(), Opts::term(), Binds::bindings()}
| {error, notfound, path}. | {error, notfound, path}.
@ -75,7 +75,7 @@ match_path(Path, [{PathMatch, Handler, Opts}|Tail], HostBinds) ->
%% Internal. %% Internal.
-spec try_match(Type::host | path, List::path_tokens(), Match::match()) -spec try_match(Type::host | path, List::path_tokens(), Match::match_rule())
-> {true, Binds::bindings()} | false. -> {true, Binds::bindings()} | false.
try_match(_Type, _List, '_') -> try_match(_Type, _List, '_') ->
{true, []}; {true, []};
@ -86,7 +86,7 @@ try_match(host, List, Match) ->
try_match(path, List, Match) -> try_match(path, List, Match) ->
list_match(List, Match, []). list_match(List, Match, []).
-spec list_match(List::path_tokens(), Match::match(), Binds::bindings()) -spec list_match(List::path_tokens(), Match::match_rule(), Binds::bindings())
-> {true, Binds::bindings()} | false. -> {true, Binds::bindings()} | false.
%% Atom '_' matches anything, continue. %% Atom '_' matches anything, continue.
list_match([_E|Tail], ['_'|TailMatch], Binds) -> list_match([_E|Tail], ['_'|TailMatch], Binds) ->