The grpc-gateway-client
is a high quality REST client generator for gRPC services that are fronted by grpc-gateway.
- Strongly typed client interface.
- Supports all gRPC features including streaming.
- Supports all grpc-gateway features including custom query parameters, and request body.
- Battle tested by Akuity's production services.
-
Install
grpc-gateway-client
:$ go install github.com/akuity/grpc-gateway-client/protoc-gen-grpc-gateway-client@latest
-
Add plugin in your buf.gen.yaml:
version: v1 managed: enabled: true plugins: - name: gateway-client path: protoc-gen-grpc-gateway-client out: pkg/api/gen opt: - paths=source_relative
-
Generate client using
buf generate
and use it in your code:client := grpc_gateway_client_example.NewGreeterGatewayClient(gateway.NewClient(baseURL)) resp, err := client.SayHello(context.Background(), &grpc_gateway_client_example.HelloRequest{Name: "World"}) if err != nil { panic(err) } fmt.Println(resp.Message)
See example for a complete example.