Documentation ¶
Index ¶
- Constants
- func HeaderMatcher(key string) (string, bool)
- func LoggerUnaryServerInterceptor(logger log.CtxLogger) grpc.UnaryServerInterceptor
- func RequestIDUnaryServerInterceptor(logger log.CtxLogger) grpc.UnaryServerInterceptor
- func WithDefaultGatewayMiddleware(logger log.CtxLogger, h http.Handler) http.Handler
- func WithErrorHandler(logger log.CtxLogger) runtime.ServeMuxOption
- func WithHTTPEndpointHeader(h http.Handler) http.Handler
- func WithPrettyJSONHeader(h http.Handler) http.Handler
- func WithPrettyJSONMarshaler() runtime.ServeMuxOption
Constants ¶
const ( // HTTPEndpointHeader is added internally by the GRPC Gateway to signal the // GRPC handler the request was actually received by an HTTP endpoint. HTTPEndpointHeader = "x-http-endpoint" // RequestIDHeader contains a value that uniquely identifies a request. RequestIDHeader = "x-request-id" )
Variables ¶
This section is empty.
Functions ¶
func HeaderMatcher ¶
func LoggerUnaryServerInterceptor ¶
func LoggerUnaryServerInterceptor(logger log.CtxLogger) grpc.UnaryServerInterceptor
LoggerUnaryServerInterceptor logs all GRPC requests when they are returned. It logs the duration, grpc method and grpc status code. If the request originated from the GRPC gateway (HTTP request) the HTTP endpoint is logged as well, assuming the GRPC gateway has the WithHTTPEndpointHeader middleware.
func RequestIDUnaryServerInterceptor ¶
func RequestIDUnaryServerInterceptor(logger log.CtxLogger) grpc.UnaryServerInterceptor
RequestIDUnaryServerInterceptor tries to fetch the request ID from metadata and generates a new request ID if not found. It also adds the request ID to the response metadata.
func WithDefaultGatewayMiddleware ¶
WithDefaultGatewayMiddleware wraps the handler with the default GRPC Gateway middleware.
func WithErrorHandler ¶
func WithErrorHandler(logger log.CtxLogger) runtime.ServeMuxOption
WithErrorHandler makes sure that we log any requests that errored out and add a request ID to the response.
func WithPrettyJSONMarshaler ¶
func WithPrettyJSONMarshaler() runtime.ServeMuxOption
WithPrettyJSONMarshaler returns a GRPC gateway ServeMuxOption which prints a pretty JSON output when Accept header contains application/json+pretty.
Types ¶
This section is empty.