Giter Site home page Giter Site logo

grpc-json-proxy's Introduction

grpc-json-proxy

GRPC JSON is a proxy which allows HTTP API tools like Postman to interact with gRPC servers.

Requirements

  • grpc+json codec must be enabled on the grpc server
  • Postman must be configured to use the proxy

Configuration of the proxy and its dependencies is a three step process.

Register a JSON codec with the gRPC server. In Go, it can be automatically registered simple by adding the following import:

import _"github.com/jnewmano/grpc-json-proxy/codec"

If you're using gogo/protobuf as your protobuf backend, import the following:

import _"github.com/jnewmano/grpc-json-proxy/gogoprotobuf/codec"

  1. Run the grpc-json-proxy. Download pre-built binaries from https://github.com/jnewmano/grpc-json-proxy/releases/ or build from source:

go get -u github.com/jnewmano/grpc-json-proxy grpc-json-proxy

  1. Configure Postman to send requests through the proxy. Postman -> Preferences -> Proxy -> Global Proxy

Proxy Server: localhost 7001

Postman Proxy Configuration

Setup your Postman gRPC request with the following:

  1. Set request method to Post .
  2. Set the URL to http://{{ grpc server address}}/{{proto package}}.{{proto service}}/{{method}} Always use http, proxy will establish a secure connection to the gRPC server.
  3. Set the Content-Type header to application/grpc+json .
  4. Optionally add a Grpc-Insecure header set to true for an insecure connection.
  5. Set the request body to appropriate JSON for the message. For reference, generated Go code includes JSON tags on the generated message structs.

For example:

Postman Example Request

Inspired by Johan Brandhorst's grpc-json

grpc-json-proxy's People

Contributors

jnewmano avatar chai-nadig avatar jrkt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.