mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Document some undefined behavior in cowboy_router
This commit is contained in:
parent
c65e3ff20e
commit
f0cae8dbcf
2 changed files with 10 additions and 0 deletions
|
@ -124,6 +124,14 @@ You can also have imbricated optional segments.
|
||||||
[source,erlang]
|
[source,erlang]
|
||||||
PathMatch = "/hats/[page/[:number]]".
|
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 `[...]`.
|
You can retrieve the rest of the host or path using `[...]`.
|
||||||
In the case of hosts it will match anything before, in the case
|
In the case of hosts it will match anything before, in the case
|
||||||
of paths anything after the previously matched segments. It is
|
of paths anything after the previously matched segments. It is
|
||||||
|
|
|
@ -428,6 +428,8 @@ compile_test_() ->
|
||||||
{[<<"horses">>], [], h, o},
|
{[<<"horses">>], [], h, o},
|
||||||
{[<<"hats">>], [], 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/[page/[:number]]", h, o}]}], [{'_', [], [
|
{[{'_', [{"/hats/[page/[:number]]", h, o}]}], [{'_', [], [
|
||||||
{[<<"hats">>], [], h, o},
|
{[<<"hats">>], [], h, o},
|
||||||
{[<<"hats">>, <<"page">>], [], h, o},
|
{[<<"hats">>, <<"page">>], [], h, o},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue