From 483ba7d5b596ecbc7602a09f0ee2546385ebe818 Mon Sep 17 00:00:00 2001 From: Daniel Pauls Date: Mon, 14 Aug 2023 22:38:13 +0200 Subject: [PATCH] Don't create a `RouteId` if routes can be merged (#2174) --- axum/src/routing/path_router.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/axum/src/routing/path_router.rs b/axum/src/routing/path_router.rs index 99b1ec2a..bd6d91ad 100644 --- a/axum/src/routing/path_router.rs +++ b/axum/src/routing/path_router.rs @@ -53,8 +53,6 @@ where validate_path(path)?; - let id = self.next_route_id(); - let endpoint = if let Some((route_id, Endpoint::MethodRouter(prev_method_router))) = self .node .path_to_route_id @@ -74,6 +72,7 @@ where Endpoint::MethodRouter(method_router) }; + let id = self.next_route_id(); self.set_node(path, id)?; self.routes.insert(id, endpoint);