poem
poem copied to clipboard
Add support for merging routes/endpoints
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);