You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Formally, a route consists of a list of segments separated by `/`, with an optional leading and trailing slash: `(/)<segment_1>/.../<segment_n>(/)`.
100
+
101
+
Given set of routes, their overlapping segments may include, in order of priority:
102
+
103
+
- Any number of static segments (`/a`, `/b`, ...).
104
+
-*One* of the following:
105
+
- Any number of route parameters with a suffix (`/{x}a`, `/{x}b`, ...), prioritizing the longest suffix.
106
+
- Any number of route parameters with a prefix (`/a{x}`, `/b{x}`, ...), prioritizing the longest prefix.
107
+
- A single route parameter with both a prefix and a suffix (`/a{x}b`).
108
+
-*One* of the following;
109
+
- A single standalone parameter (`/{x}`).
110
+
- A single standalone catch-all parameter (`/{*rest}`).
111
+
112
+
Any other combination of route segments is considered ambiguous, and attempting to insert such a route will result in an error.
113
+
114
+
The one exception to the above set of rules is that catch-all parameters are always considered to conflict with suffixed route parameters, i.e. that `/{*rest}`
115
+
and `/{x}suffix` are overlapping. This is due to an implementation detail of the routing tree that may be relaxed in the future.
116
+
88
117
## How does it work?
89
118
90
119
The router takes advantage of the fact that URL routes generally follow a hierarchical structure.
// Note that this would lead to an empty parameter value.
73
+
assert!(router.at("/").is_err());
65
74
# Ok(())
66
75
# }
67
76
```
68
77
69
-
The literal characters `{` and `}` may be included in a static route by escaping them with the same character. For example, the `{` character is escaped with `{{` and the `}` character is escaped with `}}`.
78
+
The literal characters `{` and `}` may be included in a static route by escaping them with the same character. For example, the `{` character is escaped with `{{`, and the `}` character is escaped with `}}`.
Formally, a route consists of a list of segments separated by `/`, with an optional leading and trailing slash: `(/)<segment_1>/.../<segment_n>(/)`.
114
+
115
+
Given set of routes, their overlapping segments may include, in order of priority:
116
+
117
+
- Any number of static segments (`/a`, `/b`, ...).
118
+
- *One* of the following:
119
+
- Any number of route parameters with a suffix (`/{x}a`, `/{x}b`, ...), prioritizing the longest suffix.
120
+
- Any number of route parameters with a prefix (`/a{x}`, `/b{x}`, ...), prioritizing the longest prefix.
121
+
- A single route parameter with both a prefix and a suffix (`/a{x}b`).
122
+
- *One* of the following;
123
+
- A single standalone parameter (`/{x}`).
124
+
- A single standalone catch-all parameter (`/{*rest}`).
125
+
126
+
Any other combination of route segments is considered ambiguous, and attempting to insert such a route will result in an error.
127
+
128
+
The one exception to the above set of rules is that catch-all parameters are always considered to conflict with suffixed route parameters, i.e. that `/{*rest}`
129
+
and `/{x}suffix` are overlapping. This is due to an implementation detail of the routing tree that may be relaxed in the future.
130
+
102
131
# How does it work?
103
132
104
133
The router takes advantage of the fact that URL routes generally follow a hierarchical structure. Routes are stored them in a radix trie that makes heavy use of common prefixes.
0 commit comments