Documentation ¶
Index ¶
- func BindJSON(r *http.Request, v any) error
- func DefaultErrorHandler(err error, w http.ResponseWriter, r *http.Request)
- func F(next HandlerFunc) http.Handler
- func HF(next HandlerFunc) http.HandlerFunc
- func JSON(w http.ResponseWriter, status int, v any) error
- func New(next Handler) http.Handler
- func NewWithHandler(next Handler, eh ErrorHandler) http.Handler
- type ErrorHandler
- type ErrorResponse
- type Handler
- type HandlerFunc
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindJSON ¶
Decodes a request body to v using encoding/json.
If v implements the Validator interface, calls Validate.
func DefaultErrorHandler ¶
func DefaultErrorHandler(err error, w http.ResponseWriter, r *http.Request)
func F ¶
func F(next HandlerFunc) http.Handler
Creates a new http.Handler from a httplib.HandlerFunc
func HF ¶
func HF(next HandlerFunc) http.HandlerFunc
Creates a new http.HandlerFunc from a httplib.HandlerFunc
func JSON ¶
func JSON(w http.ResponseWriter, status int, v any) error
Writes a JSON response using encoding/json.
func NewWithHandler ¶
func NewWithHandler(next Handler, eh ErrorHandler) http.Handler
Creates a new http handler with a custom error handler func
Types ¶
type ErrorHandler ¶
type ErrorHandler func(err error, w http.ResponseWriter, r *http.Request)
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Details map[string]any `json:"details"` Status int `json:"status"` }
Default error response
type HandlerFunc ¶
type HandlerFunc func(w http.ResponseWriter, r *http.Request) error
func (HandlerFunc) ServeHTTP ¶
func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) error
Click to show internal directories.
Click to hide internal directories.