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

Route Confusion #666

Open
apoliakov opened this issue Dec 6, 2024 · 0 comments
Open

Route Confusion #666

apoliakov opened this issue Dec 6, 2024 · 0 comments

Comments

@apoliakov
Copy link
Member

Reported by a user. A route/:arg can be confused with route/otheroption and cause hard-to-predict behavior. Both methods get called. For example given:

  @GetApi('/greeting/:user')
  static async oneGreeting(ctxt: HandlerContext, @ArgSource(ArgSources.URL) user: string) {
    ctxt.logger.info(`Called greeting ${user}`);
    return "thanks!"
  }

  @GetApi('/greeting/foo')
  static async anotherGreeting(ctxt: HandlerContext) {
    ctxt.logger.info(`Called the other greeting with foo`);
    return "thanks much!"
  }

If we run

curl http://localhost:3000/greeting/foo
thanks!

While the log says

2024-12-06 00:28:11 [info]: Called greeting foo 
2024-12-06 00:28:11 [info]: Called the other greeting with foo 

User who found this believes that we should error when building the app, if such a conflict is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant