Documentation
¶
Overview ¶
Package middleware provides reusable gRPC server interceptors for common production concerns such as authentication, structured logging, payload logging, and panic recovery.
The helper functions return interceptor slices so callers can compose them into their own preferred chain order.
Index ¶
- func AddAuth(authFunc grpc_auth.AuthFunc) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
- func AddLogging(logger *zap.Logger) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
- func AddPayloadLogging(logger *zap.Logger) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
- func AddRecovery() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAuth ¶ added in v0.0.3
func AddAuth( authFunc grpc_auth.AuthFunc, ) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
AddAuth returns unary and stream interceptors that enforce gRPC auth middleware.
func AddLogging ¶
func AddLogging( logger *zap.Logger, ) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
AddLogging returns unary and stream interceptors for structured gRPC logging.
Example ¶
unary, stream := AddLogging(zap.NewNop()) _, _ = unary, stream
func AddPayloadLogging ¶
func AddPayloadLogging( logger *zap.Logger, ) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
AddPayloadLogging returns interceptors that log request and response payloads in addition to standard gRPC call metadata.
Example ¶
unary, stream := AddPayloadLogging(zap.NewNop()) _, _ = unary, stream
func AddRecovery ¶
func AddRecovery() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
AddRecovery returns interceptors that convert panics in gRPC handlers into internal errors.
Example ¶
unary, stream := AddRecovery() _, _ = unary, stream
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
`grpcauth` is an authentication and authorization gRPC server side authentication wrappers.
|
`grpcauth` is an authentication and authorization gRPC server side authentication wrappers. |
|
Package zaplogger adapts zap loggers for gRPC internals and provides a small initialization helper for structured JSON logging.
|
Package zaplogger adapts zap loggers for gRPC internals and provides a small initialization helper for structured JSON logging. |