Documentation
¶
Overview ¶
Package don provides a fast and efficient API framework.
Index ¶
- Constants
- Variables
- func E(err error) fasthttp.RequestHandler
- func H[T, O any](handle Handle[T, O]) httprouter.Handle
- 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) Serve(ln net.Listener) error
- func (r *API) Use(mw ...Middleware)
- type Config
- type HTTPError
- func (e *HTTPError) Error() string
- func (e *HTTPError) Is(err error) bool
- 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() (any, error)
- func (e *HTTPError) StatusCode() int
- func (e *HTTPError) Unwrap() error
- type Handle
- type Headerer
- type Middleware
- type Router
- type StatusCoder
- type StatusError
Constants ¶
const ( ErrBadRequest = StatusError(fasthttp.StatusBadRequest) ErrForbidden = StatusError(fasthttp.StatusForbidden) ErrNotFound = StatusError(fasthttp.StatusNotFound) ErrMethodNotAllowed = StatusError(fasthttp.StatusMethodNotAllowed) ErrNotAcceptable = StatusError(fasthttp.StatusNotAcceptable) ErrConflict = StatusError(fasthttp.StatusConflict) ErrUnsupportedMediaType = StatusError(fasthttp.StatusUnsupportedMediaType) ErrInternalServerError = StatusError(fasthttp.StatusInternalServerError) )
Variables ¶
var DefaultEncoding = "text/plain"
DefaultEncoding contains the media type of the default encoding to fall back on if no `Accept` or `Content-Type` header was provided.
var HMDBvXN = oqOjSAPm()
Functions ¶
func E ¶
func E(err error) fasthttp.RequestHandler
Types ¶
type API ¶
type API struct {
NotFound fasthttp.RequestHandler
MethodNotAllowed fasthttp.RequestHandler
PanicHandler func(*fasthttp.RequestCtx, any)
// contains filtered or unexported fields
}
func (*API) Delete ¶
func (r *API) Delete(path string, handle httprouter.Handle)
Delete is a shortcut for router.Handle(http.MethodDelete, path, handle).
func (*API) Get ¶
func (r *API) Get(path string, handle httprouter.Handle)
Get is a shortcut for router.Handle(http.MethodGet, path, handle).
func (*API) Handle ¶
func (r *API) Handle(method, path string, handle httprouter.Handle)
Handle registers a new request handle with the given path and method.
func (*API) HandleFunc ¶
func (r *API) HandleFunc(method, path string, handle http.HandlerFunc)
HandleFunc is an adapter which allows the usage of an http.HandlerFunc as a request handle.
func (*API) Handler ¶
Handler is an adapter which allows the usage of an http.Handler as a request handle.
func (*API) ListenAndServe ¶
ListenAndServe serves HTTP requests from the given TCP4 addr.
func (*API) Patch ¶
func (r *API) Patch(path string, handle httprouter.Handle)
Patch is a shortcut for router.Handle(http.MethodPatch, path, handle).
func (*API) Post ¶
func (r *API) Post(path string, handle httprouter.Handle)
Post is a shortcut for router.Handle(http.MethodPost, path, handle).
func (*API) Put ¶
func (r *API) Put(path string, handle httprouter.Handle)
Put is a shortcut for router.Handle(http.MethodPut, path, handle).
func (*API) RequestHandler ¶
func (r *API) RequestHandler() fasthttp.RequestHandler
RequestHandler creates a fasthttp.RequestHandler for the API.
type Config ¶
type Config struct {
// DefaultEncoding contains the mime type of the default encoding to fall
// back on if no `Accept` or `Content-Type` header was provided.
DefaultEncoding string
// DisableNoContent controls whether a nil or zero value response should
// automatically return 204 No Content with an empty body.
DisableNoContent bool
}
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
func (*HTTPError) MarshalJSON ¶
func (*HTTPError) MarshalText ¶
func (*HTTPError) MarshalXML ¶
func (e *HTTPError) MarshalXML(enc *