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:
Jonas Platte
2022-09-25 11:56:23 +00:00
committed by GitHub
parent 2077d50021
commit 4847d681b1
17 changed files with 453 additions and 225 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ impl<B, T, F> SpaRouter<B, T, F> {
impl<B, F, T> From<SpaRouter<B, T, F>> for Router<(), B>
where
F: Clone + Send + 'static,
F: Clone + Send + Sync + 'static,
HandleError<Route<B, io::Error>, F, T>: Service<Request<B>, Error = Infallible>,
<HandleError<Route<B, io::Error>, F, T> as Service<Request<B>>>::Response: IntoResponse + Send,
<HandleError<Route<B, io::Error>, F, T> as Service<Request<B>>>::Future: Send,
@@ -161,7 +161,7 @@ where
.handle_error(spa.handle_error.clone());
Router::new()
.nest(&spa.paths.assets_path, assets_service)
.nest_service(&spa.paths.assets_path, assets_service)
.fallback_service(
get_service(ServeFile::new(&spa.paths.index_file)).handle_error(spa.handle_error),
)