grpc-dev-proxy is a proxy that allows debugging gRPC services using HTTP GUI tools like Postman or Paw.
- Supports gRPC server reflection
- Supports metadata
- gRPC reflection must be enabled on the server. It is easy to enable on supported languages listed here.
go get github.com/leafduo/grpc-dev-proxy
Start grpc-dev-proxy
:
grpc-dev-proxy
By default grpc-dev-proxy
listens on port 2333, you can change it by passing --port
:
grpc-dev-proxy --port 1234
Start your HTTP debugging tool, set the URL to http://localhost:2333
and method to POST
.
Set the following HTTP headers:
Target
: gRPC host and portService
: gRPC service nameMethod
: method you are calling
Put request message in HTTP request body in JSON format, don’t forget to change Content-Type
to application/json
.
If gRPC metadata is needed, it should go in the HTTP query string.
For example, we have the following .proto
file:
syntax = "proto3";
package helloworld;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
The gRPC server is located at localhost:50051
, and we want to make a call to helloworld.Gretter/SayHello
with name
set to world
and metadata user-id = 1
.
curl -X "POST" "http://localhost:2333/?user-id=1" \
-H 'Target: localhost:50051' \
-H 'Service: helloworld.Greeter' \
-H 'Method: SayHello' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"name": "world"
}'