Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is used for storing request context in the request context
const RequestContextKey ContextKey = "request_context"
type ErrorHandlingMiddleware ¶
type ErrorHandlingMiddleware struct {
// contains filtered or unexported fields
}
ErrorHandlingMiddleware provides enhanced error handling and logging for REST handlers
func NewErrorHandlingMiddleware ¶
func NewErrorHandlingMiddleware(logger *zap.SugaredLogger) *ErrorHandlingMiddleware
NewErrorHandlingMiddleware creates a new error handling middleware
func (*ErrorHandlingMiddleware) LogError ¶
func (m *ErrorHandlingMiddleware) LogError(r *http.Request, err error, operation string)
LogError logs an error with request context for better debugging
func (*ErrorHandlingMiddleware) WithRequestContext ¶
func (m *ErrorHandlingMiddleware) WithRequestContext(next http.Handler) http.Handler
WithRequestContext middleware adds request context for better error handling
type RequestContext ¶
type RequestContext struct { RequestID string StartTime time.Time Method string Path string ResourceType string ResourceID string UserID int }
RequestContext holds information about the current request for better error handling
func GetRequestContext ¶
func GetRequestContext(r *http.Request) *RequestContext
GetRequestContext retrieves the request context from the HTTP request
Click to show internal directories.
Click to hide internal directories.