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

Browser and gRPC-compatible HTTP APIs #4

Closed
mozey opened this issue Nov 24, 2022 · 4 comments
Closed

Browser and gRPC-compatible HTTP APIs #4

mozey opened this issue Nov 24, 2022 · 4 comments

Comments

@mozey
Copy link
Owner

mozey commented Nov 24, 2022

Protocol buffer is an alternative to tools like Swagger.

Besides the benefits of using a binary protocol, it's potentially also more efficient to develop. The "spec" / clients are generated from interfaces and structs, no comment annotations, or manually editing JSON spec is required.

connect-go is an alternative lib for "for building browser and gRPC-compatible HTTP APIs. If you're tired of hand-written boilerplate and turned off by massive frameworks, Connect is for you.". It has the following features

  • supports "three protocols: gRPC, gRPC-Web, and Connect's own protocol"
  • "works over HTTP/1.1 or HTTP/2"
  • "any package that works with an http.Server, http.Client, or http.Handler also works with Connect"

The official Google implementation of gRPC has some disadvantages

  • "has no browser support (due to vendors not implementing trailers)"
  • "is 130 thousand lines of hand-written code"
  • "uses its own implementation of HTTP/2. It's incompatible with the rest of Go's HTTP ecosystem"
  • "Supporting common HTTP clients (like web browsers) requires elaborate translating proxies"

As per gotime episode gRPC & protocol buffers

@mozey
Copy link
Owner Author

mozey commented Nov 24, 2022

Related to #3

@mozey
Copy link
Owner Author

mozey commented Nov 29, 2022

Implementing in #5

@mozey
Copy link
Owner Author

mozey commented Nov 30, 2022

Tool for generating a TypeScript client: connect-web

@mozey
Copy link
Owner Author

mozey commented Nov 30, 2022

See protobuf language spec

UPDATE Leaning above spec is not that practical. Stick to using Go structs and swagger annotations on the route handlers as in #3

@mozey mozey closed this as completed Dec 10, 2022
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