From 9942beb58cb11c0f4ba4c98145b5cd1ff94985cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 27 Nov 2012 11:35:40 +0100 Subject: Fix dispatch documentation with regards to the <<"*">> path --- src/cowboy_dispatcher.erl | 11 ++++++----- src/cowboy_static.erl | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cowboy_dispatcher.erl b/src/cowboy_dispatcher.erl index cfb8fb6..21874a9 100644 --- a/src/cowboy_dispatcher.erl +++ b/src/cowboy_dispatcher.erl @@ -21,7 +21,7 @@ -type bindings() :: [{atom(), binary()}]. -type tokens() :: [binary()]. --type match_rule() :: '_' | '*' | [binary() | '_' | '...' | atom()]. +-type match_rule() :: '_' | <<_:8>> | [binary() | '_' | '...' | atom()]. -type dispatch_path() :: [{match_rule(), module(), any()}]. -type dispatch_rule() :: {Host::match_rule(), Path::dispatch_path()}. -type dispatch_rules() :: [dispatch_rule()]. @@ -45,9 +45,10 @@ %% PathRules being a list of {Path, HandlerMod, HandlerOpts}. %% %% Hostname and Path are match rules and can be either the -%% atom '_', which matches everything for a single token, the atom -%% '*', which matches everything for the rest of the tokens, or a -%% list of tokens. Each token can be either a binary, the atom '_', +%% atom '_', which matches everything, <<"*">>, which match the +%% wildcard path, or a list of tokens. +%% +%% Each token can be either a binary, the atom '_', %% the atom '...' or a named atom. A binary token must match exactly, %% '_' matches everything for a single token, '...' matches %% everything for the rest of the tokens and a named atom will bind the @@ -96,7 +97,7 @@ match_path([], _, _, _) -> {error, notfound, path}; match_path([{'_', Handler, Opts}|_Tail], HostInfo, _, Bindings) -> {ok, Handler, Opts, Bindings, HostInfo, undefined}; -match_path([{'*', Handler, Opts}|_Tail], HostInfo, '*', Bindings) -> +match_path([{<<"*">>, Handler, Opts}|_Tail], HostInfo, <<"*">>, Bindings) -> {ok, Handler, Opts, Bindings, HostInfo, undefined}; match_path([{PathMatch, Handler, Opts}|Tail], HostInfo, Tokens, Bindings) when is_list(Tokens) -> diff --git a/src/cowboy_static.erl b/src/cowboy_static.erl index 724bf33..1b4ff89 100644 --- a/src/cowboy_static.erl +++ b/src/cowboy_static.erl @@ -158,7 +158,7 @@ %% {file, <<"index.html">>}]} %% %% %% Serve cowboy/priv/www/page.html under http://example.com/*/page -%% {['*', <<"page">>], cowboy_static, +%% {['_', <<"page">>], cowboy_static, %% [{directory, {priv_dir, cowboy, [<<"www">>]}} %% {file, <<"page.html">>}]}. %% -- cgit v1.2.3