Documentation
¶
Overview ¶
Package web contains helpers for web handlers
Index ¶
- func ErrorText(code int) string
- func WithErrorHandler(ctx context.Context, h ErrorHandlerFunc) context.Context
- type Error
- type ErrorHandlerFunc
- type HTTPError
- func (err *HTTPError) AddHeader(key, value string)
- func (err *HTTPError) DeleteHeader(key string)
- func (err *HTTPError) Error() string
- func (err *HTTPError) Header() http.Header
- func (err *HTTPError) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (err *HTTPError) SetHeader(key, value string)
- func (err *HTTPError) Status() int
- func (err *HTTPError) Unwrap() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithErrorHandler ¶
func WithErrorHandler(ctx context.Context, h ErrorHandlerFunc) context.Context
WithErrorHandler attaches an ErrorHandler function to a context for later retrieval
Types ¶
type ErrorHandlerFunc ¶
type ErrorHandlerFunc func(http.ResponseWriter, *http.Request, error)
ErrorHandlerFunc is the signature of a function used as ErrorHandler
func ErrorHandler ¶
func ErrorHandler(ctx context.Context) (ErrorHandlerFunc, bool)
ErrorHandler attempts to pull an ErrorHandler from the context.Context
type HTTPError ¶
HTTPError extends core.WrappedError with HTTP Status Code
func NewHTTPError ¶
NewHTTPError creates a new HTTPError with a given StatusCode and optional cause and annotation
func NewHTTPErrorf ¶
NewHTTPErrorf creates a new HTTPError with a given StatusCode and optional cause and formatted annotation
func (*HTTPError) DeleteHeader ¶
DeleteHeader removes a header key from the HTTPError if present
func (*HTTPError) Header ¶
Header returns a http.Header attached to this error for custom fields
func (*HTTPError) ServeHTTP ¶
func (err *HTTPError) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP is a very primitive handler that will try to pass the error to a [middleware.ErrorHandlerFunc] provided via the request's context.Context
Directories
¶
Path | Synopsis |
---|---|
Package html facilitates use of html/template.Template
|
Package html facilitates use of html/template.Template |
Package qlist provides a processor for HTTP Quality Lists
|
Package qlist provides a processor for HTTP Quality Lists |
Package respond assists handlers to produce reponses
|
Package respond assists handlers to produce reponses |