Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for merging routes/endpoints #399

Open
choco opened this issue Sep 27, 2022 · 0 comments
Open

Add support for merging routes/endpoints #399

choco opened this issue Sep 27, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@choco
Copy link

choco commented Sep 27, 2022

It would be nice if there was support for merging routes like Axum, this is especially usefull when breaking down routes in multiple modules.

Description of the feature

The feature is well described here https://docs.rs/axum/latest/axum/routing/struct.Router.html#method.merge
I tried to replicate the same in poem with nest but it panics complaining about duplicate entries.

In my case for example I'd like to have somethign like this.

mod module_a {
  fn routes() -> impl Endpoint { todo!() }
}

mod module_b {
  fn routes() -> impl Endpoint { todo!() }
}

let routes_a = module_a::routes();
let routes_b = module_b::routes();
let final_routes = Routes::new()
    .merge(routes_a)
    .merge(routes_b)
    .with(Tracing);
@choco choco added the enhancement New feature or request label Sep 27, 2022
@choco choco changed the title Add support for merging routes Add support for merging routes/endpoints Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant