-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
A-axumC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.
Description
- I have looked for existing issues (including closed) about this
Bug Report
Version
- axum 0.7
Description
I'm trying to turn a Router into a Service so I can use it in root_router.nest_service(...)
.
- Router has a
.into_service()
method Router::nest_service
requires the service to implementClone
- Router does implement
Clone
. - RouterIntoService does not implement
Clone
.
All of that together means that, while I can write code that does
let sub_router = submod::create_router();
let router = Router::new()
.nest("/sub", sub_router);
I can not write code that does
let sub_router_service = submod::create_router().into_service();
let router = Router::new()
.nest_service("/sub", sub_router_service);
This seems like it might be an oversight? It looks to me like RouterIntoService should trivially implement Clone
? (It only has a Router in it.)
Why do I want to use .nest_service
instead of .nest
in the first place? It's because I have a layer on my subrouter, and when I use .nest
that layer doesn't get called for non-matching routes.
Metadata
Metadata
Assignees
Labels
A-axumC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.