Documentation ¶
Overview ¶
Package gateway defines a grpc-gateway server that serves HTTP-JSON traffic and acts a proxy between HTTP and gRPC.
Index ¶
- func SwaggerServer() http.HandlerFunc
- type Gateway
- func (g *Gateway) Start()
- func (g *Gateway) Status() error
- func (g *Gateway) Stop() error
- func (g *Gateway) WithAllowedOrigins(origins []string) *Gateway
- func (g *Gateway) WithApiMiddleware(endpointFactory apimiddleware.EndpointFactory) *Gateway
- func (g *Gateway) WithMaxCallRecvMsgSize(size uint64) *Gateway
- func (g *Gateway) WithRemoteCert(cert string) *Gateway
- func (g *Gateway) WithRouter(r *mux.Router) *Gateway
- type MuxHandler
- type PbHandlerRegistration
- type PbMux
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) WithAllowedOrigins ¶
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 ¶
WithMaxCallRecvMsgSize allows specifying the maximum allowed gRPC message size.
func (*Gateway) WithRemoteCert ¶
WithRemoteCert allows adding a custom certificate to the gateway,
type MuxHandler ¶
MuxHandler is a function that implements the mux handler functionality.
type PbHandlerRegistration ¶
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.