ApiMethodRouter does not implement Clone
michael-weigelt opened this issue · 1 comments
michael-weigelt commented
Hi, I have the following code working with Axum's MethodRouter, but not with Aide::axum's ApiMethodRouter, because the latter does not implement Clone. Is that on purpose? Is there a workaround for when I need to pass the methodrouter several times?
Thanks for any help!
pub trait RouterExt<S, B>
where
B: HttpBody + Send + 'static,
S: Clone + Send + Sync + 'static,
{
fn directory_route(self, path: &str, method_router: ApiMethodRouter<S, B>) -> Self;
}
impl<S, B> RouterExt<S, B> for ApiRouter<S, B>
where
B: HttpBody + Send + 'static,
S: Clone + Send + Sync + 'static,
{
fn directory_route(self, path: &str, method_router: ApiMethodRouter<S, B>) -> Self {
self.route(path, method_router.clone())
.api_route(&format!("{path}/"), method_router)
}
}
tamasfe commented
I was not aware that axum's router implemented Clone
, if that's the case, then this is a bug.