Documentation
¶
Index ¶
- Variables
- func Bind(c fiber.Ctx, obj interface{}) error
- func BindBody(r fiber.Ctx, obj interface{}) error
- func BindQuery(c fiber.Ctx, obj interface{}) error
- func BindUri(c fiber.Ctx, obj interface{}) error
- func MustBindWith(c fiber.Ctx, obj interface{}, b Binding) error
- func NewReq[REQ any](c fiber.Ctx) (*REQ, error)
- func RegisterBodyBinding(name string, unmarshaller func(data []byte, obj any) error)
- func SetTag(tag string)
- func ShouldBind(c fiber.Ctx, obj interface{}) error
- func ShouldBindBody(c fiber.Ctx, obj interface{}) error
- func ShouldBindQuery(c fiber.Ctx, obj interface{}) error
- func ShouldBindUri(c fiber.Ctx, obj interface{}) error
- func ShouldBindWith(c fiber.Ctx, obj interface{}, b Binding) error
- type ArgsSource
- type Binding
- type BindingBody
- type CtxSource
- type HeaderSource
- type MultipartRequest
- type QuerySource
Constants ¶
This section is empty.
Variables ¶
var ( CustomBody = bodyBinding{/* contains filtered or unexported fields */} Query = queryBinding{} FormPost = formPostBinding{} FormMultipart = formMultipartBinding{} Uri = uriBinding{} Header = headerBinding{} )
Functions ¶
func BindQuery ¶
func BindQuery(c fiber.Ctx, obj interface{}) error
BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).
func BindUri ¶
func BindUri(c fiber.Ctx, obj interface{}) error
MustBindWith binds the passed struct pointer using the specified binding engine. BindUri binds the passed struct pointer using binding.Uri. It will abort the request with HTTP 400 if any error occurs.
func MustBindWith ¶
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 ¶
func ShouldBind ¶
func ShouldBind(c fiber.Ctx, 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 ¶
func ShouldBindBody(c fiber.Ctx, obj interface{}) error
func ShouldBindQuery ¶
func ShouldBindQuery(c fiber.Ctx, obj interface{}) error
ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).
func ShouldBindUri ¶
func ShouldBindUri(c fiber.Ctx, obj interface{}) error
ShouldBindUri binds the passed struct pointer using the specified binding engine.
func ShouldBindWith ¶
ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.
Types ¶
type ArgsSource ¶ added in v0.3.8
func (*ArgsSource) TrySet ¶ added in v0.3.8
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 BindingBody ¶
type CtxSource ¶ added in v0.3.8
type CtxSource fasthttp.RequestCtx
type HeaderSource ¶ added in v0.3.8
type HeaderSource fasthttp.RequestHeader
func (*HeaderSource) Peek ¶ added in v0.3.8
func (form *HeaderSource) Peek(key string) ([]string, bool)
func (*HeaderSource) TrySet ¶ added in v0.3.8
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 ¶ added in v0.3.8
func (*MultipartRequest) TrySet ¶ added in v0.3.8
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