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

Duplicate handlers do not cause a compilation error #126

Closed
szagi3891 opened this issue Dec 14, 2021 · 8 comments
Closed

Duplicate handlers do not cause a compilation error #126

szagi3891 opened this issue Dec 14, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@szagi3891
Copy link

Expected Behavior

I would expect that the macro would not allow this code to compile

Actual Behavior

When we have duplicate handlers, the code compiles.

    #[oai(method = "get", path = "/fun1")]
    async fn fun1(&self) -> PlainText<String> {
        PlainText("response from fun1".into())
    }

    #[oai(method = "get", path = "/fun1")]
    async fn fun2(&self) -> PlainText<String> {
        PlainText("response from fun2".into())
    }

Steps to Reproduce the Problem

  1. You have to clone https://github.com/szagi3891/poem-test
  2. And then run with cargo run

Specifications

  • Version: poem = "1.0.38", poem-openapi = "1.0.41"
  • Platform: MacOs
  • Subsystem:
@szagi3891 szagi3891 added the bug Something isn't working label Dec 14, 2021
@sunli829
Copy link
Collaborator

I cannot detect duplicate paths at compile time, but I can panic at runtime.

@szagi3891
Copy link
Author

@sunli829 Is it possible to make this panic happen when starting the application?

@sunli829
Copy link
Collaborator

Yes. If there are duplicate paths, a panic will occur when starting the application. 🙂

@sunli829
Copy link
Collaborator

Released in v1.2.6

@szagi3891
Copy link
Author

Something is still not working. Here I have an example of such duplicate handlers:
https://github.com/szagi3891/poem-test/blob/master/src/main.rs#L142

When I run cargo run, the server gets up (no panic). And it should panic with a message that "GET /fun1" is duplicated

@sunli829
Copy link
Collaborator

This can be detected in the macro, I forgot to do this. 🙂

@sunli829
Copy link
Collaborator

Fixed in v1.2.7

@szagi3891
Copy link
Author

Fantastic. It works perfectly. Thank you very much :)

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

No branches or pull requests

2 participants