ConnectRPC support for gRPC service
Feature Request
Crates
volo-grpc
Motivation
ConnectRPC allows gRPC services to be called directly from browsers and with tools like cURL, without needing proxies or gateways. This would make Volo services much easier to integrate with web frontends.
Example - calling a service with cURL:
curl --header "Content-Type: application/json" \
--data '{"name": "test"}' \
https://api.example.com/service.v1.MyService/Method
Proposal
Add ConnectRPC protocol support to volo-grpc so a single server can handle:
- Standard gRPC (for service-to-service)
- Connect protocol (for browsers, buf curl and its toolchain)
The implementation would detect the protocol based on Content-Type headers and handle Connect's simpler HTTP/1.1 compatible format for unary calls. For streaming RPC I think it's a bit tricky, especially for the bidirectional streaming as it currently only supported with HTTP/2 transport, however there's a potential where it can be established with HTTP/1.1 by doing chunked transfer encoding, and to note that the server should support full duplex (eg. in Go https://pkg.go.dev/net/http#ResponseController.EnableFullDuplex)
Alternatives
TBD
Hello, to better understand your needs, we would like to ask about your specific scenario. There are two points that need to be confirmed:
- What is the current infrastructure and network path? Does it need to traverse a proxy/CDN that only supports HTTP/1.1?
- Whether the front-end can use the gRPC-Web protocol and accept the debugging cost of such a protocol?
If you just need to solve the problem of browser access to grpc service, you can use grpc-web, which we have natively supported in volo. The usage example is in https://github.com/cloudwego/volo/tree/main/examples/src/grpc/grpc-web.
If you must need the connect protocol, could you please contribute to the implementation of the Connect protocol server?