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

Prefixing path of all operations in a service #2233

Closed
ShahOdin opened this issue Apr 9, 2024 · 3 comments
Closed

Prefixing path of all operations in a service #2233

ShahOdin opened this issue Apr 9, 2024 · 3 comments

Comments

@ShahOdin
Copy link

ShahOdin commented Apr 9, 2024

Let's say I have:

service MyService {
    version: "v1"
    operations: [Foo, Bar, Baz]
}

I'd like my operations to be available at:

  • v1/foo
  • v1/bar
  • v1/baz

so that when I make changes to the api and get v2, I can deploy both versions side by side and get both:

  • v1/foo
  • v2/foo

etc.

Can I do this without hardcoding this for every operation individually?

@mtdowling
Copy link
Member

Two approaches to this come to mind: include the version in the http trait (the simplest option and seems like it would make the model more accurate), or make this kind of prefixing part of endpoint resolution.

Lots of services need a prefix when they deploy their service. One reason might be that they run multiple services from the same host and disambiguate based on a base path. In these cases, the prefix isn't really part of the API itself but rather part of where the API is hosted. As such, path prefixing is handled in the endpoint resolution of the service. So when a client resolves the endpoint, it also gets a base path of v1 or v2 that it concatenates with the path of the API.

@ShahOdin
Copy link
Author

include the version in the http trait

http trait only targets operation. like I said, I don't want this to be done at the operation level. if I have 10 ooerations, I want to be able to consistently change it for all of them.

In these cases, the prefix isn't really part of the API itself but rather part of where the API is hosted.

fair point here tho.

@mtdowling
Copy link
Member

Yeah it would need to be per operation. I think it’s manageable organizationally if you add a validator to ensure the prefix is consistent. We don’t have plans to add a kind of shared prefix to any of the built-in HTTP traits. A protocol trait could add this if they wanted though. Barring that, using endpoints addresses this.

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