mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Allow Routers to inherit state (#1368)
* Rename Fallback::Custom to Fallback::Service
* Allow Routers to inherit state
* Rename Router::{nest => nest_service} and add new nest method for Routers
* Fix lints
* Add basic tests for state inheritance
* Changelog
This commit is contained in:
@@ -58,7 +58,7 @@ async fn main() {
|
||||
)
|
||||
.route("/keys", get(list_keys))
|
||||
// Nest our admin routes under `/admin`
|
||||
.nest("/admin", admin_routes(shared_state).into_service())
|
||||
.nest("/admin", admin_routes(shared_state))
|
||||
// Add middleware to all routes
|
||||
.layer(
|
||||
ServiceBuilder::new()
|
||||
|
||||
@@ -131,7 +131,7 @@ where
|
||||
// to prevent directory traversal attacks we ensure the path consists of exactly one normal
|
||||
// component
|
||||
fn path_is_valid(path: &str) -> bool {
|
||||
let path = std::path::Path::new(&*path);
|
||||
let path = std::path::Path::new(path);
|
||||
let mut components = path.components().peekable();
|
||||
|
||||
if let Some(first) = components.peek() {
|
||||
|
||||
Reference in New Issue
Block a user