Clarify documentation about route_layer (#2154)

This commit is contained in:
Max
2023-08-08 11:40:38 +00:00
committed by GitHub
parent 54e203cd51
commit edfb1cece3
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -2,8 +2,9 @@ Apply a [`tower::Layer`] to the router that will only run if the request matches
a route. a route.
Note that the middleware is only applied to existing routes. So you have to Note that the middleware is only applied to existing routes. So you have to
first add your routes (and / or fallback) and then call `layer` afterwards. Additional first add your routes (and / or fallback) and then call `route_layer`
routes added after `layer` is called will not have the middleware added. afterwards. Additional routes added after `route_layer` is called will not have
the middleware added.
This works similarly to [`MethodRouter::layer`] except the middleware will only run if This works similarly to [`MethodRouter::layer`] except the middleware will only run if
the request matches a route. This is useful for middleware that return early the request matches a route. This is useful for middleware that return early
+3 -2
View File
@@ -2,8 +2,9 @@ Apply a [`tower::Layer`] to the router that will only run if the request matches
a route. a route.
Note that the middleware is only applied to existing routes. So you have to Note that the middleware is only applied to existing routes. So you have to
first add your routes (and / or fallback) and then call `layer` afterwards. Additional first add your routes (and / or fallback) and then call `route_layer`
routes added after `layer` is called will not have the middleware added. afterwards. Additional routes added after `route_layer` is called will not have
the middleware added.
This works similarly to [`Router::layer`] except the middleware will only run if This works similarly to [`Router::layer`] except the middleware will only run if
the request matches a route. This is useful for middleware that return early the request matches a route. This is useful for middleware that return early