Documentation ¶
Index ¶
- Constants
- Variables
- func E(err error) fasthttp.RequestHandler
- func H[T, O any](handle Handle[T, O]) httprouter.Handle
- func RegisterDecoder[T DecoderConstraint](contentType string, dec T, aliases ...string)
- func RegisterEncoder[T EncoderConstraint](contentType string, enc T, aliases ...string)
- type API
- func (r *API) Delete(path string, handle httprouter.Handle)
- func (r *API) Get(path string, handle httprouter.Handle)
- func (r *API) Group(path string) Router
- func (r *API) Handle(method, path string, handle httprouter.Handle)
- func (r *API) HandleFunc(method, path string, handle http.HandlerFunc)
- func (r *API) Handler(method, path string, handle http.Handler)
- func (r *API) ListenAndServe(addr string) error
- func (r *API) Patch(path string, handle httprouter.Handle)
- func (r *API) Post(path string, handle httprouter.Handle)
- func (r *API) Put(path string, handle httprouter.Handle)
- func (r *API) RequestHandler() fasthttp.RequestHandler
- func (r *API) Use(mw ...Middleware)
- type Config
- type ContextMarshaler
- type ContextUnmarshaler
- type DecoderConstraint
- type Empty
- type EncoderConstraint
- type HTTPError
- func (e *HTTPError) Error() string
- func (e *HTTPError) MarshalJSON() ([]byte, error)
- func (e *HTTPError) MarshalText() ([]byte, error)
- func (e *HTTPError) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (e *HTTPError) MarshalYAML() (interface{}, error)
- func (e *HTTPError) StatusCode() int
- type Handle
- type Headerer
- type Marshaler
- type Middleware
- type RequestParser
- type ResponseEncoder
- type Router
- type StatusCoder
- type StatusError
- func (e StatusError) Error() string
- func (e StatusError) MarshalJSON() ([]byte, error)
- func (e StatusError) MarshalText() ([]byte, error)
- func (e StatusError) MarshalXML(enc *xml.Encoder, _ xml.StartElement) error
- func (e StatusError) MarshalYAML() (interface{}, error)
- func (e StatusError) StatusCode() int
- type Unmarshaler
Constants ¶
View Source
const ( ErrBadRequest = StatusError(http.StatusBadRequest) ErrForbidden = StatusError(http.StatusForbidden) ErrNotFound = StatusError(http.StatusNotFound) ErrMethodNotAllowed = StatusError(http.StatusMethodNotAllowed) ErrNotAcceptable = StatusError(http.StatusNotAcceptable) ErrUnsupportedMediaType = StatusError(http.StatusUnsupportedMediaType) ErrInternalServerError = StatusError(http.StatusInternalServerError) )
Variables ¶
View Source
var DefaultEncoding = "text/plain"
Functions ¶
func E ¶
func E(err error) fasthttp.RequestHandler
func H ¶
func H[T, O any](handle Handle[T, O]) httprouter.Handle
H wraps your handler function with the Go generics magic.
func RegisterDecoder ¶
func RegisterDecoder[T DecoderConstraint](contentType string, dec T, aliases ...string)
RegisterDecoder registers a request decoder.
func RegisterEncoder ¶
func RegisterEncoder[T EncoderConstraint](contentType string, enc T, aliases ...string)
RegisterEncoder registers a response encoder.
Types ¶
type API ¶
type API struct { NotFound fasthttp.RequestHandler MethodNotAllowed fasthttp.RequestHandler PanicHandler func(*fasthttp.RequestCtx, interface{}) // contains filtered or unexported fields }
func (*API) HandleFunc ¶
func (r *API) HandleFunc(method, path string, handle http.HandlerFunc)
func (*API) ListenAndServe ¶
func (*API) RequestHandler ¶
func (r *API) RequestHandler() fasthttp.RequestHandler
RequestHandler creates a fasthttp.RequestHandler for the API.
func (*API) Use ¶
func (r *API) Use(mw ...Middleware)
type ContextMarshaler ¶
type ContextUnmarshaler ¶
type DecoderConstraint ¶
type DecoderConstraint interface { Unmarshaler | ContextUnmarshaler | RequestParser }
type EncoderConstraint ¶
type EncoderConstraint interface { Marshaler | ContextMarshaler | ResponseEncoder }
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
func (*HTTPError) MarshalJSON ¶
func (*HTTPError) MarshalText ¶
func (*HTTPError) MarshalXML ¶
func (*HTTPError) MarshalYAML ¶
func (*HTTPError) StatusCode ¶
type Middleware ¶
type Middleware func(fasthttp.RequestHandler) fasthttp.RequestHandler
type RequestParser ¶
type RequestParser = func(ctx *fasthttp.RequestCtx, v interface{}) error
type ResponseEncoder ¶
type ResponseEncoder = func(ctx *fasthttp.RequestCtx, v interface{}) error
type Router ¶
type Router interface { Get(path string, handle httprouter.Handle) Post(path string, handle httprouter.Handle) Put(path string, handle httprouter.Handle) Delete(path string, handle httprouter.Handle) Handle(method, path string, handle httprouter.Handle) Handler(method, path string, handle http.Handler) HandleFunc(method, path string, handle http.HandlerFunc) Group(path string) Router Use(mw ...Middleware) }
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
StatusCoder allows you to customise the HTTP response code.
type StatusError ¶
type StatusError int
StatusError creates an error from an HTTP status code.
func (StatusError) Error ¶
func (e StatusError) Error() string
func (StatusError) MarshalJSON ¶
func (e StatusError) MarshalJSON() ([]byte, error)
func (StatusError) MarshalText ¶
func (e StatusError) MarshalText() ([]byte, error)
func (StatusError) MarshalXML ¶
func (e StatusError) MarshalXML(enc *xml.Encoder, _ xml.StartElement) error
func (StatusError) MarshalYAML ¶
func (e StatusError) MarshalYAML() (interface{}, error)
func (StatusError) StatusCode ¶
func (e StatusError) StatusCode() int
type Unmarshaler ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.