From edfb1cece3d19c9a210c64575ec7e2ed8366bc33 Mon Sep 17 00:00:00 2001 From: Max <maxdev@posteo.de> Date: Tue, 8 Aug 2023 13:40:38 +0200 Subject: [PATCH] Clarify documentation about `route_layer` (#2154) --- axum/src/docs/method_routing/route_layer.md | 5 +++-- axum/src/docs/routing/route_layer.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/axum/src/docs/method_routing/route_layer.md b/axum/src/docs/method_routing/route_layer.md index 7a7ff36a..501b5517 100644 --- a/axum/src/docs/method_routing/route_layer.md +++ b/axum/src/docs/method_routing/route_layer.md @@ -2,8 +2,9 @@ Apply a [`tower::Layer`] to the router that will only run if the request matches a route. 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 -routes added after `layer` is called will not have the middleware added. +first add your routes (and / or fallback) and then call `route_layer` +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 the request matches a route. This is useful for middleware that return early diff --git a/axum/src/docs/routing/route_layer.md b/axum/src/docs/routing/route_layer.md index 5e60eaf5..bc7b2197 100644 --- a/axum/src/docs/routing/route_layer.md +++ b/axum/src/docs/routing/route_layer.md @@ -2,8 +2,9 @@ Apply a [`tower::Layer`] to the router that will only run if the request matches a route. 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 -routes added after `layer` is called will not have the middleware added. +first add your routes (and / or fallback) and then call `route_layer` +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 the request matches a route. This is useful for middleware that return early