Documentation
¶
Index ¶
- func DefaultOnError(w http.ResponseWriter, r *http.Request, err error) error
- func DeflateEncodingReader(r io.Reader) (io.ReadCloser, error)
- func GZipEncodingReader(r io.Reader) (io.ReadCloser, error)
- func RequestBodyHandler(h http.Handler, defaults ...Option) http.Handler
- func SetRequestBodyOption(r *http.Request, opts ...Option)
- type BadRequestError
- type Encoding
- type EncodingReader
- type Option
- type RequestBodyError
- type RequestContentLengthRequiredError
- type RequestContentTooLargeError
- type RequestUnsupportedMediaTypeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOnError ¶
DefaultOnError is the default error handler for the lazyReader. It handles specific errors like MaxBytesError and sets the appropriate HTTP status. For other errors, it simply returns the error.
func DeflateEncodingReader ¶
func DeflateEncodingReader(r io.Reader) (io.ReadCloser, error)
func GZipEncodingReader ¶
func GZipEncodingReader(r io.Reader) (io.ReadCloser, error)
func RequestBodyHandler ¶
RequestBodyHandler is middleware for handling content encoding and content length. When configuring the handler, you can specify options such as maximum content length, supported encodings, and an error handler.
The configuration is only evaluated at the point of reading the request body, giving handlers the opportunity to override the defaults on a per-request basis.
Wrapped handlers can override the default options on a per-request basis using the `SetRequestBodyOption` function to set options on the request context.
func SetRequestBodyOption ¶
Types ¶
type BadRequestError ¶
type BadRequestError struct {
Err error
}
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
func (*BadRequestError) RecommendedStatusCode ¶
func (e *BadRequestError) RecommendedStatusCode() int
type EncodingReader ¶
type EncodingReader func(r io.Reader) (io.ReadCloser, error)
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func ContentLengthLimit ¶
func DisableEncoding ¶
func RequireContentLength ¶
func SupportEncoding ¶
func SupportEncoding(name string, reader EncodingReader) Option
type RequestBodyError ¶
type RequestContentLengthRequiredError ¶
type RequestContentLengthRequiredError struct {
}
func (*RequestContentLengthRequiredError) Error ¶
func (e *RequestContentLengthRequiredError) Error() string
func (*RequestContentLengthRequiredError) RecommendedStatusCode ¶
func (e *RequestContentLengthRequiredError) RecommendedStatusCode() int
type RequestContentTooLargeError ¶
type RequestContentTooLargeError struct {
Limit int64
}
func (*RequestContentTooLargeError) Error ¶
func (e *RequestContentTooLargeError) Error() string
func (*RequestContentTooLargeError) RecommendedStatusCode ¶
func (e *RequestContentTooLargeError) RecommendedStatusCode() int
type RequestUnsupportedMediaTypeError ¶
type RequestUnsupportedMediaTypeError struct {
Encoding string
}
func (*RequestUnsupportedMediaTypeError) Error ¶
func (e *RequestUnsupportedMediaTypeError) Error() string
func (*RequestUnsupportedMediaTypeError) RecommendedStatusCode ¶
func (e *RequestUnsupportedMediaTypeError) RecommendedStatusCode() int