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

ApiMethodRouter does not implement Clone #89

Closed
michael-weigelt opened this issue Nov 29, 2023 · 1 comment · Fixed by #90
Closed

ApiMethodRouter does not implement Clone #89

michael-weigelt opened this issue Nov 29, 2023 · 1 comment · Fixed by #90
Labels
bug Something isn't working

Comments

@michael-weigelt
Copy link

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 tamasfe added the bug Something isn't working label Nov 29, 2023
@tamasfe
Copy link
Owner

tamasfe commented Nov 29, 2023

I was not aware that axum's router implemented Clone, if that's the case, then this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants