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
Turn off checks for compatibility with route matching syntax from 0.7.
2
+
3
+
This allows usage of paths starting with a colon `:` or an asterisk `*` which are otherwise prohibited.
4
+
5
+
# Example
6
+
7
+
```rust
8
+
useaxum::{
9
+
routing::get,
10
+
Router,
11
+
};
12
+
13
+
letapp=Router::<()>::new()
14
+
.without_v07_checks()
15
+
.route("/:colon", get(||async {}))
16
+
.route("/*asterisk", get(||async {}));
17
+
18
+
// Our app now accepts
19
+
// - GET /:colon
20
+
// - GET /*asterisk
21
+
# let_:Router=app;
22
+
```
23
+
24
+
Adding such routes without calling this method first will panic.
25
+
26
+
```rust,should_panic
27
+
use axum::{
28
+
routing::get,
29
+
Router,
30
+
};
31
+
32
+
// This panics...
33
+
let app = Router::<()>::new()
34
+
.route("/:colon", get(|| async {}));
35
+
```
36
+
37
+
# Merging
38
+
39
+
When two routers are merged, v0.7 checks are disabled if both of the two routers had them also disabled.
40
+
41
+
# Nesting
42
+
43
+
Each router needs to have the checks explicitly disabled. Nesting a router with the checks either enabled or disabled has no effect on the outer router.
expected = "Path segments must not start with `:`. For capture groups, use `{capture}`. If you meant to literally match a segment starting with a colon, call `without_v07_checks` on the router."
expected = "Path segments must not start with `*`. For wildcard capture, use `{*wildcard}`. If you meant to literally match a segment starting with an asterisk, call `without_v07_checks` on the router."
expected = "Path segments must not start with `:`. For capture groups, use `{capture}`. If you meant to literally match a segment starting with a colon, call `without_v07_checks` on the router."
expected = "Path segments must not start with `*`. For wildcard capture, use `{*wildcard}`. If you meant to literally match a segment starting with an asterisk, call `without_v07_checks` on the router."
0 commit comments