gateway

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 20 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 HttpResponseModifier

func HttpResponseModifier(ctx context.Context, w http.ResponseWriter, _ proto.Message) error

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, opts ...Option) (*Gateway, error)

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.

type MuxHandler

type MuxHandler func(
	apiMiddlewareHandler *apimiddleware.ApiProxyMiddleware,
	h http.HandlerFunc,
	w http.ResponseWriter,
	req *http.Request,
)

MuxHandler is a function that implements the mux handler functionality.

type Option

type Option func(g *Gateway) error

func WithAllowedOrigins

func WithAllowedOrigins(origins []string) Option

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

func WithApiMiddleware

func WithApiMiddleware(endpointFactory apimiddleware.EndpointFactory) Option

WithApiMiddleware allows adding an API middleware proxy to the gateway.

func WithGatewayAddr

func WithGatewayAddr(addr string) Option

func WithMaxCallRecvMsgSize

func WithMaxCallRecvMsgSize(size uint64) Option

WithMaxCallRecvMsgSize allows specifying the maximum allowed gRPC message size.

func WithMuxHandler

func WithMuxHandler(m MuxHandler) Option

func WithPbHandlers

func WithPbHandlers(handlers []*PbMux) Option

func WithRemoteAddr

func WithRemoteAddr(addr string) Option

func WithRemoteCert

func WithRemoteCert(cert string) Option

WithRemoteCert allows adding a custom certificate to the gateway,

func WithRouter

func WithRouter(r *mux.Router) Option

WithRouter allows adding a custom mux router to the gateway.

func WithTimeout

func WithTimeout(seconds uint64) Option

WithTimeout allows changing the timeout value for API calls.

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