httpgrpc

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2020 License: MIT Imports: 6 Imported by: 0

README

httpgrpc

GoDoc Build Status GitHub tag (latest SemVer) Coverage Status Go Report Card Maintainability GitHub

Golang Microservice API to convert external HTTP endpoints on a proxy to internally exposed GRPC messages. Allows a generic proxy to talk to services via a standard message while still allowing each service to maintain its API using GRPC and protocol buffers.

There are multiple implemenations that follow this basic intent already (HTTP+JSON reverse proxied to GRPC) but assume your service is directly handling external HTTP traffic, rather than sitting behind load-balanced webservers in a DMZ somewhere separate to your nice safe application server. For example, here and here.

This differs, in that your application is only expected to be handling GRPC. The logic used by the reverse proxy to determine where to send the message is up to you, this library simply sets the standard for what must be passed on - an HTTP method, a procedure name and the JSON payload. Your service must provide a procedure with a name that matches the format MethodnameProcedureName, such as PostLogin or GetUserPhoto.

Installation

go get "github.com/LLKennedy/httpgrpc"

Basic Usage

TODO

Testing

On windows, the simplest way to test is to use the powershell script.

./test.ps1

To emulate the testing which occurs in build pipelines for linux and mac, run the following:

go test ./... -race

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer added in v0.2.0

func NewServer(api interface{}, server interface{}, listener *grpc.Server) (*proxy.Server, error)

NewServer creates a new server to convert httpgrpc/proto messages to service-specific messages

func ProxyRequest added in v0.2.0

func ProxyRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, procedure string, conn *grpc.ClientConn, txid string, loggers ...logs.Writer)

ProxyRequest proxies an HTTP request through a GRPC connection compliant with httpgrpc/proto

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL