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

Support grpc-web with JSON #2020

Open
kjvalencik opened this issue Oct 25, 2024 · 0 comments
Open

Support grpc-web with JSON #2020

kjvalencik opened this issue Oct 25, 2024 · 0 comments

Comments

@kjvalencik
Copy link

Feature Request

Add support for application/grpc-web+json which is identical to grpc-web, but uses the canonical JSON representation instead of protobuf.

Crates

  • tonic-web
  • tonic

Motivation

grpc-web+json is advantageous for browser based clients because data is serialized in a format natively understood by JavaScript (JSON). Eliminating protobuf serialization can reduce library dependency and significantly reduce package sizing while also providing performance benefits.

Proposal

Detect Content-Type: application/grpc-web+json and switch to the Json codec in tonic-web.

Alternatives

This may be especially difficult because, currently, supporting both grpc and grpc+json requires building twice and switching codec implementations based on headers. See #851.

As an alternative, tonic-web could be updated to be agnostic of the content type and applications could switch services based on content type similar to workaround for grpc+json.

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

1 participant