Documentation
¶
Index ¶
- Constants
- func GenerateUUID() string
- func GetError(r *http.Request) error
- func GetHandlerResponse(r *http.Request) interface{}
- func HandlerResponse(next http.Handler) http.Handler
- func RequestID(logger *slog.Logger) mux.MiddlewareFunc
- func RequestLog(logger *slog.Logger) mux.MiddlewareFunc
- func SetError(r *http.Request, err error)
- func SetHandlerResponse(r *http.Request, response interface{})
- type DefaultHandlerResponse
Constants ¶
View Source
const RequestIDKey = "requestID"
RequestIDKey is the key used to store the request ID in the context
Variables ¶
This section is empty.
Functions ¶
func GetHandlerResponse ¶
func HandlerResponse ¶
HandlerResponse is the middleware function for handling response and errors
func RequestID ¶
func RequestID(logger *slog.Logger) mux.MiddlewareFunc
RequestID is a middleware that adds a unique request id to the request context
func RequestLog ¶
func RequestLog(logger *slog.Logger) mux.MiddlewareFunc
RequestLog is a middleware that logs request details
func SetHandlerResponse ¶
Types ¶
type DefaultHandlerResponse ¶
type DefaultHandlerResponse struct {
Code int `json:"code" dc:"Error code"`
Message string `json:"message" dc:"Error message"`
Data interface{} `json:"data" dc:"Result data for certain request according API definition"`
}
DefaultHandlerResponse is the default implementation of HandlerResponse.
Click to show internal directories.
Click to hide internal directories.