Skip to content

RouterIntoService not Clone? #2455

@bryanburgers

Description

@bryanburgers
  • 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(...).

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

No one assigned

    Labels

    A-axumC-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions