-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs, tests, and nesting for matchit
- Loading branch information
Showing
6 changed files
with
186 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Turn off checks for compatibility with route matching syntax from 0.7. | ||
|
||
This allows usage of paths starting with a colon `:` or an asterisk `*` which are otherwise prohibited. | ||
|
||
# Example | ||
|
||
```rust | ||
use axum::{ | ||
routing::get, | ||
Router, | ||
}; | ||
|
||
let app = Router::<()>::new() | ||
.without_v07_checks() | ||
.route("/:colon", get(|| async {})) | ||
.route("/*asterisk", get(|| async {})); | ||
|
||
// Our app now accepts | ||
// - GET /:colon | ||
// - GET /*asterisk | ||
# let _: Router = app; | ||
``` | ||
|
||
Adding such routes without calling this method first will panic. | ||
|
||
```rust,should_panic | ||
use axum::{ | ||
routing::get, | ||
Router, | ||
}; | ||
// This panics... | ||
let app = Router::<()>::new() | ||
.route("/:colon", get(|| async {})); | ||
``` | ||
|
||
# Merging | ||
|
||
When two routers are merged, v0.7 checks are disabled if both of the two routers had them also disabled. | ||
|
||
# Nesting | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters