grpcgateway

package
v0.0.0-...-eb00df8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultServeMuxOption = []runtime.ServeMuxOption{
	runtime.WithErrorHandler(DefaultErrorHandler),
	runtime.WithRoutingErrorHandler(DefaultRoutingErrorHandler),
	runtime.WithIncomingHeaderMatcher(DefaultHeaderWarp),

	runtime.WithMarshalerOption("application/json", &runtime.JSONPb{
		MarshalOptions: protojson.MarshalOptions{
			EmitUnpopulated: true,
			UseProtoNames:   true,
		},
		UnmarshalOptions: protojson.UnmarshalOptions{
			DiscardUnknown: false,
		},
	}),

	runtime.WithMarshalerOption("application/jsonpb", &runtime.JSONPb{
		MarshalOptions: protojson.MarshalOptions{
			EmitUnpopulated: true,
			UseProtoNames:   true,
		},
		UnmarshalOptions: protojson.UnmarshalOptions{
			DiscardUnknown: false,
		},
	}),

	runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{
		MarshalOptions: protojson.MarshalOptions{
			EmitUnpopulated: true,
			UseProtoNames:   true,
		},
		UnmarshalOptions: protojson.UnmarshalOptions{
			DiscardUnknown: false,
		},
	}),
}

Functions

func AddToHeaderAllowList

func AddToHeaderAllowList(allowList ...string)

func DefaultErrorHandler

func DefaultErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, err error)

func DefaultHTTPServer

func DefaultHTTPServer(handler http.Handler) *http.Server

func DefaultHeaderWarp

func DefaultHeaderWarp(key string) (string, bool)

func DefaultRoutingErrorHandler

func DefaultRoutingErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, httpStatus int)

func GRPCGatewayListener

func GRPCGatewayListener(mux cmux.CMux) net.Listener

func GRPCServerListener

func GRPCServerListener(mux cmux.CMux) net.Listener

func HTTPServer

func HTTPServer(handler http.Handler, warps ...func(http.Handler) http.Handler) *http.Server

func NewMixedPortServeMux

func NewMixedPortServeMux(ctx context.Context, endpoint string, registers ...Register) (*runtime.ServeMux, error)

func WithLogger

func WithLogger(handler http.Handler) http.Handler

func WithOpenTelemetry

func WithOpenTelemetry(handler http.Handler) http.Handler

func WithResponseWriter

func WithResponseWriter(handler http.Handler) http.Handler

Types

type Register

type Register func(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (ResponseWriter) Write

func (w ResponseWriter) Write(body []byte) (int, error)

Jump to

Keyboard shortcuts

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