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

Implement Twirp protocol v7 #182

Merged
merged 3 commits into from
Nov 11, 2020
Merged

Implement Twirp protocol v7 #182

merged 3 commits into from
Nov 11, 2020

Conversation

ccmtaylor
Copy link
Member

@ccmtaylor ccmtaylor commented Oct 30, 2020

  • update HTTP status code mapping for resource_exhausted error
  • make /twirp HTTP path prefix configurable
  • json: include default values in server responses

fixes #181.

@ccmtaylor ccmtaylor requested review from oberkowitz and a team October 30, 2020 17:38
* modify mapping in HTTP server
* client: generate correct code for 429s from intermediaries
@ccmtaylor ccmtaylor marked this pull request as ready for review November 3, 2020 11:25
@ccmtaylor
Copy link
Member Author

let's preserve the commits when merging this. They're separate changes, but I chose to group them in this PR.

) {

def register[T: AsProtoService](svc: T): ServerBuilder = {
val protoService = implicitly[AsProtoService[T]].asProtoService(svc)
this.copy(endpoints = endpoints ++ protoService.rpcs)
}

def withPrefix(prefix: String): ServerBuilder = {
require(prefix.startsWith("/"), "prefix must start with slash")
require(!prefix.endsWith("/"), "prefix must not end with slash")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move these checks out of this method? Otherwise I can just do ServerBuilder(prefix = "badpath/") or similar and the validation won't catch it.

Copy link
Contributor

@dziemba dziemba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (just one small note) 👍

* add parameter with default value "/twirp" to
  - ServerBuilder constructor
  - generated client constructors
  - generated `MyService.server()` method
* breaking change: remove EndpointMetadata.path method
  the method didn't actually represent the HTTP path anymore,
  so it didn't make sense.
Upstream Twirp recomends this behaviour to reduce confusion.
This is fully backwards-compatible.

See-Also: twitchtv/twirp#271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Implement Twirp protocol v7
2 participants