Skip to content

A prototype of serving both HTTP and gRPC traffic from a single spec.

Notifications You must be signed in to change notification settings

ivanRylach/hello-grpc-gateway

Repository files navigation

Kong + gRPC-gateway

A prototype of serving both HTTP and gRPC traffic from a single spec.

HTTP traffic is proxied to the gRPC server by Kong with grpc-gateway plugin.

Spec

proto files

Run Server

# 1. build the gRPC server and its docker image
make build_image

# 2. start kong and gRPC server
docker-compose up

# 3. create Kong resources
make kong

Client

Requires:

Read entity

# HTTP
curl localhost:8000/v1/messages/qwe

# gRPC
grpcurl -plaintext -d '{"name":"qwe"}' localhost:9000 ivanrylach.hello_grpc.v1.HelloService/SayHello

Create entity

# HTTP
curl -XPOST localhost:8000/v1/messages -d '{"name":"world"}'

# gRPC
grpcurl -plaintext -d '{"name":"world"}' localhost:9000 ivanrylach.hello_grpc.v1.HelloService/CreateHello

Caveats

proto files for gRPC services with HTTP annotations require following import:

import "google/api/annotations.proto";

grpc-gateway fails to import these definitions, when the parent file is copied inside of Kong docker image. It is commented out for now.

About

A prototype of serving both HTTP and gRPC traffic from a single spec.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published