Documentation ¶
Index ¶
- Variables
- func Bind(c *fasthttp.RequestCtx, obj interface{}) error
- func BindBody(r *fasthttp.RequestCtx, obj interface{}) error
- func BindQuery(r *fasthttp.RequestCtx, obj interface{}) error
- func MustBindWith(r *fasthttp.RequestCtx, obj interface{}, b Binding) error
- func NewReq[REQ any](c *fasthttp.RequestCtx) (*REQ, error)
- func RegisterBodyBinding(name string, unmarshaller func(data []byte, obj any) error)
- func SetTag(tag string)
- func ShouldBind(r *fasthttp.RequestCtx, obj interface{}) error
- func ShouldBindBody(r *fasthttp.RequestCtx, obj interface{}) error
- func ShouldBindQuery(r *fasthttp.RequestCtx, obj interface{}) error
- func ShouldBindWith(r *fasthttp.RequestCtx, obj interface{}, b Binding) error
- type ArgsSource
- type Binding
- type BindingBody
- type CtxSource
- type HeaderSource
- type MultipartRequest
Constants ¶
This section is empty.
Variables ¶
var ( CustomBody = bodyBinding{/* contains filtered or unexported fields */} Query = queryBinding{} FormPost = formPostBinding{} FormMultipart = formMultipartBinding{} Header = headerBinding{} )
Functions ¶
func Bind ¶
func Bind(c *fasthttp.RequestCtx, obj interface{}) error
func BindBody ¶ added in v0.3.0
func BindBody(r *fasthttp.RequestCtx, obj interface{}) error
func BindQuery ¶
func BindQuery(r *fasthttp.RequestCtx, obj interface{}) error
BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).
func MustBindWith ¶
func MustBindWith(r *fasthttp.RequestCtx, obj interface{}, b Binding) error
MustBindWith binds the passed struct pointer using the specified binding engine. It will abort the request with HTTP 400 if any error occurs. See the binding package.
func RegisterBodyBinding ¶ added in v0.1.9
func ShouldBind ¶
func ShouldBind(r *fasthttp.RequestCtx, obj interface{}) error
ShouldBind checks the Content-Type to select a binding engine automatically, Depending the "Content-Type" header different bindings are used:
"application/json" --> JSON binding "application/xml" --> XML binding
otherwise --> returns an error It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input. It decodes the json payload into the struct specified as a pointer. Like c.GinBind() but this method does not set the response status code to 400 and abort if the json is not valid.
func ShouldBindBody ¶ added in v0.3.0
func ShouldBindBody(r *fasthttp.RequestCtx, obj interface{}) error
func ShouldBindQuery ¶
func ShouldBindQuery(r *fasthttp.RequestCtx, obj interface{}) error
ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).
func ShouldBindWith ¶
func ShouldBindWith(r *fasthttp.RequestCtx, obj interface{}, b Binding) error
ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.
Types ¶
type ArgsSource ¶
func (*ArgsSource) TrySet ¶
func (form *ArgsSource) TrySet(value reflect.Value, field *reflect.StructField, tagValue string, opt mtos.SetOptions) (isSet bool, err error)
TrySet tries to set a value by request's form source (like map[string][]string)
type Binding ¶
type Binding interface { Name() string Bind(*fasthttp.RequestCtx, interface{}) error }
type BindingBody ¶
type CtxSource ¶
type CtxSource fasthttp.RequestCtx
type HeaderSource ¶
type HeaderSource fasthttp.RequestHeader
func (*HeaderSource) TrySet ¶
func (form *HeaderSource) TrySet(value reflect.Value, field *reflect.StructField, tagValue string, opt mtos.SetOptions) (isSet bool, err error)
TrySet tries to set a value by request's form source (like map[string][]string)
type MultipartRequest ¶
func (*MultipartRequest) TrySet ¶
func (r *MultipartRequest) TrySet(value reflect.Value, field *reflect.StructField, key string, opt mtos.SetOptions) (isSet bool, err error)
TrySet tries to set a value by the multipart request with the binding a form file