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

Allow optional request headers #2

Merged
merged 2 commits into from
Feb 12, 2023
Merged

Conversation

darronschall
Copy link
Contributor

This allows callers to add optional request headers on a per-call basis.

For example, to supply an HttpHeaders.IfNoneMatch value for ETag caching if the Twirp service supports it, like the twirp-rails gem does. Another optional use might be sending an Idempotency-Key header for idempotent requests.

Example usage of the generated code might look something like:

val eTagHeader = mapOf(HttpHeaders.IfNoneMatch to eTagValue)
val response = exampleService.getCacheableData(EmptyRequest(), eTagHeader)

This allows callers to add optional request headers on a per-call basis. For example, to supply an `HttpHeaders.IfNoneMatch` value for [ETag caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) if the Twirp service supports it, like [the `twirp-rails` gem does](https://github.com/collectiveidea/twirp-rails#basic-caching-with-etagsif-none-match-headers). Another optional use might be sending an `Idempotency-Key` header for idempotent requests.
@darronschall darronschall merged commit c85b803 into main Feb 12, 2023
@darronschall darronschall deleted the allow-optional-request-headers branch February 13, 2023 03:29
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

Successfully merging this pull request may close these issues.

2 participants