-
Notifications
You must be signed in to change notification settings - Fork 325
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
Optional /twirp prefix #263
Comments
This is a very welcome change. We use https://github.com/go-chi/chi as our mux and found composing the router meant we couldn't easily build "normal" handlers alongside twirp services (which are really just handlers).
Furthermore, depending on the service we had to expose the /twirp prefix in the ingress, which isn't ideal. Then we trim prefix, but leads to all sort of gotchas when following the request. So being able to drop the /twirp prefix would really help cleanup code (for some of us). Happy to contribute. Whether reviewing, implementing or testing. :) |
Implemented on #264 and released as part of v7 |
Proposal to update the Twirp route protocol from the current pattern:
to a new pattern where the
/twirp
prefix is optional and can be changed for any other prefix:Examples of valid Twirp URLs with different prefixes:
Backwards compatibility
This is a backwards-compatible change.
Existing clients and services will use the
/twirp
prefix by default, but the constructors will offer a new option to specify a different prefix, or use an empty value for no prefix.Implementation
PR: #264
For other languages, some implementations are already prepared for "v6 routes" (removing the /twirp prefix was part of the v6 protocol draft, but it ended up being canceled). For example, the Twirp-Ruby already requires services to be mounted on routes like "http://localhost:3000/twirp" where the "twirp" prefix is already part of the baseURL. This Twirp-Typescript implementation have an option to generate code with the "v6" option to avoid adding the "/twirp" prefix.
Other languages can follow a similar process to the Go PR to allow optional prefixes.
Related issues
Similar attempts to change the
/twirp
prefix and routing were made before. Adding them here for reference, and also how they compare to this proposal:<package>.<Service>/<Method>
will not be changed, which makes backwards compatibility a lot easier. However, that issue contains valuable comments about changing the route scheme. Please check for more details.The text was updated successfully, but these errors were encountered: