Documentation
¶
Index ¶
- Constants
- Variables
- func ContextualLoggerUnary(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
- func RequestIdHttpForwardResponseOption(ctx context.Context, w http.ResponseWriter, _ proto.Message) error
- func RequestIdUnary(ctx context.Context, req any, _ *grpc.UnaryServerInfo, ...) (any, error)
- type ErrorInterceptor
Constants ¶
View Source
const (
RequestIDHeader string = "X-Request-Id"
)
Variables ¶
View Source
var ErrInternalError = errors.New("internal server error")
Functions ¶
func ContextualLoggerUnary ¶
func ContextualLoggerUnary( ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (any, error)
ContextualLoggerUnary Enriches the context with tenant and request metadata for structured logging.
This interceptor extracts tenant related information (such as tenant ID, app ID, etc.) from the incoming context, as well as the full gRPC method name and the current request.
Downstream handlers can then use log.FromContext(ctx) to access and include these enriched fields in their log entries.
func RequestIdHttpForwardResponseOption ¶
func RequestIdHttpForwardResponseOption( ctx context.Context, w http.ResponseWriter, _ proto.Message, ) error
RequestIdHttpForwardResponseOption gets the request ID added in the gRPC context and injects it in the HTTP response
func RequestIdUnary ¶
func RequestIdUnary( ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (any, error)
RequestIdUnary injects a request ID in the gRPC context
Types ¶
type ErrorInterceptor ¶
type ErrorInterceptor struct {
// contains filtered or unexported fields
}
func NewErrorInterceptor ¶
func NewErrorInterceptor(isProd bool) *ErrorInterceptor
func (ErrorInterceptor) Unary ¶
func (i ErrorInterceptor) Unary( ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (any, error)
Click to show internal directories.
Click to hide internal directories.