aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/guide/routing.asciidoc8
-rw-r--r--src/cowboy_router.erl2
2 files changed, 10 insertions, 0 deletions
diff --git a/doc/src/guide/routing.asciidoc b/doc/src/guide/routing.asciidoc
index 47ef3c5..e5f8c33 100644
--- a/doc/src/guide/routing.asciidoc
+++ b/doc/src/guide/routing.asciidoc
@@ -124,6 +124,14 @@ You can also have imbricated optional segments.
[source,erlang]
PathMatch = "/hats/[page/[:number]]".
+While Cowboy does not reject multiple brackets in a route,
+the behavior may be undefined if the route is under-specified.
+For example, this route requires constraints to determine what
+is a chapter and what is a page, since they are both optional:
+
+[source,erlang]
+PathMatch = "/book/[:chapter]/[:page]".
+
You can retrieve the rest of the host or path using `[...]`.
In the case of hosts it will match anything before, in the case
of paths anything after the previously matched segments. It is
diff --git a/src/cowboy_router.erl b/src/cowboy_router.erl
index 754e3e7..44a7e18 100644
--- a/src/cowboy_router.erl
+++ b/src/cowboy_router.erl
@@ -428,6 +428,8 @@ compile_test_() ->
{[<<"horses">>], [], h, o},
{[<<"hats">>], [], h, o},
{[<<"hats">>, <<"page">>, number], [], h, o}]}]},
+ {[{'_', [{"/hats/:page/:number", h, o}]}], [{'_', [], [
+ {[<<"hats">>, page, number], [], h, o}]}]},
{[{'_', [{"/hats/[page/[:number]]", h, o}]}], [{'_', [], [
{[<<"hats">>], [], h, o},
{[<<"hats">>, <<"page">>], [], h, o},