Skip to content

leafduo/grpc-dev-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grpc-dev-proxy

grpc-dev-proxy is a proxy that allows debugging gRPC services using HTTP GUI tools like Postman or Paw.

Feature

Requirements

  • gRPC reflection must be enabled on the server. It is easy to enable on supported languages listed here.

Installation

go get github.com/leafduo/grpc-dev-proxy

Usage

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 port
  • Service: gRPC service name
  • Method: 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.

Example

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

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"
}'

Paw

headers body metadata

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages