Documentation
¶
Index ¶
- Variables
- func SetJSONCodec(marshal jsonMarshalFunc, unmarshal jsonUnmarshalFunc)
- type Accept
- type Ctx
- func (c *Ctx) Abort()
- func (c *Ctx) AbortWithStatus(code int)
- func (c *Ctx) AbortWithStatusJSON(code int, v any)
- func (c *Ctx) Bind(v any) error
- func (c *Ctx) BindForm(v any) error
- func (c *Ctx) BindJSON(v any) error
- func (c *Ctx) ClientIP() string
- func (c *Ctx) File(path string)
- func (c *Ctx) FileAttachment(path, filename string)
- func (c *Ctx) GetHeader(key string) string
- func (c *Ctx) IsAborted() bool
- func (c *Ctx) JSON(code int, v any)
- func (c *Ctx) Negotiate(code int, a Accept)
- func (c *Ctx) Next()
- func (c *Ctx) Param(key string) string
- func (c *Ctx) ParamInt(key string) (int, error)
- func (c *Ctx) Query(key string) string
- func (c *Ctx) Redirect(code int, url string)
- type Engine
- func (e *Engine) DELETE(path string, h ...Handler)
- func (e *Engine) GET(path string, h ...Handler)
- func (e *Engine) Group(prefix string, mws ...Handler) *Router
- func (e *Engine) HEAD(path string, h ...Handler)
- func (e *Engine) Handler() fasthttp.RequestHandler
- func (e *Engine) Listen(addr string) error
- func (e *Engine) NoMethod(h ...Handler)
- func (e *Engine) NoRoute(h ...Handler)
- func (e *Engine) OPTIONS(path string, h ...Handler)
- func (e *Engine) PATCH(path string, h ...Handler)
- func (e *Engine) POST(path string, h ...Handler)
- func (e *Engine) PUT(path string, h ...Handler)
- func (e *Engine) SetRemoteIPHeaders(headers ...string)
- func (e *Engine) SetTrustedProxies(proxies ...string) error
- func (e *Engine) Static(prefix, rootDir string)
- func (e *Engine) StaticFS(prefix string, fsys fs.FS)
- func (e *Engine) Use(mws ...Handler)
- type Handler
- type Router
- func (r *Router) DELETE(path string, h ...Handler)
- func (r *Router) GET(path string, h ...Handler)
- func (r *Router) Group(prefix string, mws ...Handler) *Router
- func (r *Router) HEAD(path string, h ...Handler)
- func (r *Router) PATCH(path string, h ...Handler)
- func (r *Router) POST(path string, h ...Handler)
- func (r *Router) PUT(path string, h ...Handler)
- func (r *Router) Static(prefix, rootDir string)
- func (r *Router) StaticFS(prefix string, fsys fs.FS)
- func (r *Router) Use(mws ...Handler)
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedMediaType = errors.New("flare: unsupported media type")
returned by Bind for content-types other than json/form
Functions ¶
func SetJSONCodec ¶
func SetJSONCodec(marshal jsonMarshalFunc, unmarshal jsonUnmarshalFunc)
swaps json encode/decode (nil arg keeps current)
Types ¶
type Ctx ¶
type Ctx struct {
*fasthttp.RequestCtx
// contains filtered or unexported fields
}
pooled request context wrapping *fasthttp.RequestCtx
func (*Ctx) AbortWithStatusJSON ¶
write json, then abort
func (*Ctx) Bind ¶
decode body from content-type (json or form-urlencoded) call from handlers only, not from router hot path
func (*Ctx) BindForm ¶
fill exported string/int fields from post args (form tag, else json, else name) reflect-based, also keep off hot path
func (*Ctx) ClientIP ¶
returns client address if socket peer is listed in SetTrustedProxies, headers from SetRemoteIPHeaders are consulted w/o anything configured headers are ignored and the peer address is returned
func (*Ctx) File ¶ added in v0.1.1
File sends a local file as the response body, do not pass user-supplied paths
func (*Ctx) FileAttachment ¶ added in v0.1.1
FileAttachment sends a local file as a download named filename empty filename uses filepath.Base(path), do not pass user-supplied paths
type Engine ¶
type Engine struct {
// when true, miss that matches same method with slash flipped redirects
// (301 GET, 307 otherwise). default false keeps strict /a vs /a/
RedirectTrailingSlash bool
// fasthttp limits/timeouts; override before Listen
Server fasthttp.Server
// contains filtered or unexported fields
}
fasthttp router trailing slashes are significant by default; see RedirectTrailingSlash
func New ¶
func New() *Engine
new engine w/ conservative server defaults (4mib body, 10s r/w, 60s idle)
func (*Engine) Handler ¶
func (e *Engine) Handler() fasthttp.RequestHandler
fasthttp handler; freezes routes on first call
func (*Engine) SetRemoteIPHeaders ¶
overrides header list used when peer is trusted defaults restored with nothing passed
func (*Engine) SetTrustedProxies ¶
set cidrs/bare ips allowed to supply forwarded-client headers empty means clientip always returns sock peer
func (*Engine) Static ¶
serve from rootdir under prefix (get+head) prefix / serves the directory at the site root
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
route group with shared prefix and middleware