grpc

package
v0.0.0-...-6ad1837 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHandlerFactory

func GetHandlerFactory(
	opts *Options,
	registerables ...Registerable,
) http.HandlerFactory

GetHandlerFactory takes (possibly nil) options and a list of Registerables and returns a pkg/http.HandlerFactory to create a net/http.Handler that serves both a gRPC server and its gRPC Gateway.

Types

type GatewayRegisterFunc

type GatewayRegisterFunc func(
	ctx context.Context,
	mux *runtime.ServeMux,
	endpoint string,
	opts []googlegrpc.DialOption,
) error

GatewayRegisterFunc is a function that registers a gRPC service in a gRPC Gateway ServeMux.

type Options

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

Options holds the options to get a pkg/http.HandlerFactory.

func (*Options) WithBeforeGateway

func (o *Options) WithBeforeGateway(middlewares ...http.Middleware) *Options

WithBeforeGateway appends a list of http.Middlewares to the Options object that will be executed right before the gRPC gateway handler.

func (*Options) WithBeforeH2C

func (o *Options) WithBeforeH2C(middlewares ...http.Middleware) *Options

WithBeforeH2C appends a list of http.Middlewares to the Options object that will be executed before everything else.

func (*Options) WithBeforeRootMux

func (o *Options) WithBeforeRootMux(middlewares ...http.Middleware) *Options

WithBeforeRootMux appends a list of http.Middlewares to the Options object that will be executed after the H2C handler and before the routing to gRPC server or gRPC Gateway.

func (*Options) WithBeforeServer

func (o *Options) WithBeforeServer(middlewares ...http.Middleware) *Options

WithBeforeServer appends a list of http.Middlewares to the Options object that will be executed right before the gRPC server handler.

func (*Options) WithGatewayMuxOptions

func (o *Options) WithGatewayMuxOptions(opts ...runtime.ServeMuxOption) *Options

WithGatewayMuxOptions appends a list of gRPC Gateway ServeMux options to the Options object.

func (*Options) WithServerOptions

func (o *Options) WithServerOptions(opts ...googlegrpc.ServerOption) *Options

WithServerOptions appends a list of gRPC Server options to the Options object.

type Registerable

type Registerable interface {
	// Register registers the Registerable in the given google/grpc.Server.
	Register(server *googlegrpc.Server)

	// GetGatewayRegisterFunc returns the GatewayRegisterFunc of the Registerable.
	GetGatewayRegisterFunc() GatewayRegisterFunc
}

Registerable represents an object that knows to register itself in a gRPC server and its gRPC Gateway.

Jump to

Keyboard shortcuts

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