Documentation ¶
Overview ¶
Package gateway defines a grpc-gateway server that serves HTTP-JSON traffic and acts a proxy between HTTP and gRPC.
Index ¶
- func HttpResponseModifier(ctx context.Context, w http.ResponseWriter, _ proto.Message) error
- type Gateway
- type MuxHandler
- type Option
- func WithAllowedOrigins(origins []string) Option
- func WithGatewayAddr(addr string) Option
- func WithMaxCallRecvMsgSize(size uint64) Option
- func WithMuxHandler(m MuxHandler) Option
- func WithPbHandlers(handlers []*PbMux) Option
- func WithRemoteAddr(addr string) Option
- func WithRemoteCert(cert string) Option
- func WithRouter(r *mux.Router) Option
- func WithTimeout(seconds uint64) Option
- type PbHandlerRegistration
- type PbMux
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HttpResponseModifier ¶
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.
type MuxHandler ¶
type MuxHandler func( h http.HandlerFunc, w http.ResponseWriter, req *http.Request, )
MuxHandler is a function that implements the mux handler functionality.
type Option ¶
func WithAllowedOrigins ¶
WithAllowedOrigins allows adding a set of allowed origins to the gateway.
func WithGatewayAddr ¶
func WithMaxCallRecvMsgSize ¶
WithMaxCallRecvMsgSize allows specifying the maximum allowed gRPC message size.
func WithMuxHandler ¶
func WithMuxHandler(m MuxHandler) Option
func WithPbHandlers ¶
func WithRemoteAddr ¶
func WithRemoteCert ¶
WithRemoteCert allows adding a custom certificate to the gateway,
func WithRouter ¶
WithRouter allows adding a custom mux router to the gateway.
func WithTimeout ¶
WithTimeout allows changing the timeout value for API calls.
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.