Spec compatibility for go server and client #245
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #244
Through a PR on twirpy, I discovered that the go and python official implementations do not conform to the spec wrt CamelCasing the URL. There is a difference between the python client and go server implementation as well.
My initial assumption was go might be the reference implementation and spec kind of follows the behaviour in go generated code. So I opened #244 to ask if/how we should add clarification on the spec.
@spenczar pointed out that it is probably supposed to be the other way around.
Overview of choices
The major trade off seems to be between breaking change in spec vs the go server implementation.
The fact that this hasn't been an issue so far is most probably because people using twirp, especially in other languages, make their service and method names CamelCased anyway.
That might be at least some weak evidence in favour of doubling down on camel case requirement for all implementations.
On the other hand, it an also be seen as the impact of a breaking change might not be that big.
If we think of twirp as a serious alternative to gRPC and REST, we're still in the early stages of the lifetime penetration it will have across languages. This project relies heavily on community implementations of the spec for that.
A move to maintain simplicity of the spec might be of greater importance from that view.
Description of changes:
This PR pre-emptively assumes we want to go towards being compatible with the spec and switch the go implementation over time. So it takes the first safe step towards that.
For the service definition
Go server now accepts both cases of method name to ensure compatibility with older go clients:
/twirp/simple.Hello/world
/twirp/simple.Hello/World
Go client sends requests to
/twirp/simple.Hello/world
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.