gateway

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package gateway defines a grpc-gateway server that serves HTTP-JSON traffic and acts a proxy between HTTP and gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwaggerServer

func SwaggerServer() http.HandlerFunc

SwaggerServer returns swagger specification files located under "/swagger/"

Types

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway is the gRPC gateway to serve HTTP JSON traffic as a proxy and forward it to the gRPC server.

func New

func New(
	ctx context.Context,
	pbHandlers []*PbMux,
	muxHandler MuxHandler,
	remoteAddr,
	gatewayAddress string,
) *Gateway

New returns a new instance of the Gateway.

func (*Gateway) Start

func (g *Gateway) Start()

Start the gateway service.

func (*Gateway) Status

func (g *Gateway) Status() error

Status of grpc gateway. Returns an error if this service is unhealthy.

func (*Gateway) Stop

func (g *Gateway) Stop() error

Stop the gateway with a graceful shutdown.

func (*Gateway) WithAllowedOrigins

func (g *Gateway) WithAllowedOrigins(origins []string) *Gateway

WithAllowedOrigins allows adding a set of allowed origins to the gateway.

func (*Gateway) WithApiMiddleware

func (g *Gateway) WithApiMiddleware(endpointFactory apimiddleware.EndpointFactory) *Gateway

WithApiMiddleware allows adding API Middleware proxy to the gateway.

func (*Gateway) WithMaxCallRecvMsgSize

func (g *Gateway) WithMaxCallRecvMsgSize(size uint64) *Gateway

WithMaxCallRecvMsgSize allows specifying the maximum allowed gRPC message size.

func (*Gateway) WithRemoteCert

func (g *Gateway) WithRemoteCert(cert string) *Gateway

WithRemoteCert allows adding a custom certificate to the gateway,

func (*Gateway) WithRouter

func (g *Gateway) WithRouter(r *mux.Router) *Gateway

WithRouter allows adding a custom mux router to the gateway.

type MuxHandler

type MuxHandler func(http.Handler, http.ResponseWriter, *http.Request)

MuxHandler is a function that implements the mux handler functionality.

type PbHandlerRegistration

type PbHandlerRegistration func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error

PbHandlerRegistration is a function that registers a protobuf handler.

type PbMux

type PbMux struct {
	Registrations []PbHandlerRegistration // Protobuf registrations to be registered in Mux.
	Patterns      []string                // URL patterns that will be handled by Mux.
	Mux           *gwruntime.ServeMux     // The router that will be used for grpc-gateway requests.
}

PbMux serves grpc-gateway requests for selected patterns using registered protobuf handlers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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