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

Routing for ambiguous service endpoints is not specified #305

Closed
sfackler opened this issue May 8, 2019 · 6 comments
Closed

Routing for ambiguous service endpoints is not specified #305

sfackler opened this issue May 8, 2019 · 6 comments

Comments

@sfackler
Copy link
Member

sfackler commented May 8, 2019

Consider the following (legal) Conjure definition:

services:
  FooService:
    name: FooService
    package: com.palantir.conjure
    base-path: /foo
    endpoints:
      first:
        http: GET /foo/{param}
        args:
          param: string
      second:
        http: GET /{param}/foo
        args:
          param: string

What is the expected behavior if I make an HTTP request to /foo/foo/foo? That matches both endpoint definitions.

@ferozco
Copy link
Contributor

ferozco commented May 8, 2019

We specify this (with an example) in the docs. In your case, /foo/foo/foo would match with /foo/{param}

@sfackler
Copy link
Member Author

sfackler commented May 8, 2019

Ideally we'd have a rule and not one example.

@ferozco
Copy link
Contributor

ferozco commented May 8, 2019

agreed. I'll flesh out the rule

@sfackler
Copy link
Member Author

sfackler commented May 8, 2019

While you're in there, it'd be great to handle #297 as well :)

@ferozco
Copy link
Contributor

ferozco commented May 8, 2019

Actually, it seems like I can't read the docs. We already specify: When comparing multiple paths, the path with the longest concrete path should be matched first.

@ferozco ferozco closed this as completed May 8, 2019
@sfackler
Copy link
Member Author

sfackler commented May 8, 2019

That still sounds ambiguous to me I think. Imagine GET /foo/{param1}/bar/{param2} and GET /foo/{param1}/{param2}/bar. They both have a 1-element concrete path, right?

Assuming I understand what's intended, a more robust specification could be something like:

Convert the candidate paths into sequences of literal/parameter values, and take the lexicographic maximum with literal being greater than parameter.

In the example above, that'd look like comparing [concrete, param, concrete, param] and [concrete, param, param, concrete], and the first path would be matched.

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

2 participants