binding

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: MIT, Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CustomBody    = bodyBinding{/* contains filtered or unexported fields */}
	Query         = queryBinding{}
	FormPost      = formPostBinding{}
	FormMultipart = formMultipartBinding{}
	Uri           = uriBinding{}
	Header        = headerBinding{}
)

Functions

func Bind

func Bind(c fiber.Ctx, obj interface{}) error

func BindBody added in v0.3.0

func BindBody(r fiber.Ctx, obj interface{}) error

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

func MustBindWith(c fiber.Ctx, 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 NewReq

func NewReq[REQ any](c fiber.Ctx) (*REQ, error)

func RegisterBodyBinding added in v0.1.9

func RegisterBodyBinding(name string, unmarshaller func(data []byte, obj any) error)

func SetTag added in v0.1.10

func SetTag(tag string)

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 added in v0.3.0

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

func ShouldBindWith(c fiber.Ctx, obj interface{}, b Binding) error

ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.

Types

type Binding

type Binding interface {
	Name() string

	Bind(fiber.Ctx, interface{}) error
}

func Body

func Body(contentType []byte) Binding

func Default

func Default(method string, contentType []byte) Binding

type BindingBody

type BindingBody interface {
	Binding
	BindBody([]byte, interface{}) error
}

type QuerySource added in v0.3.0

type QuerySource map[string]string

func (QuerySource) Peek added in v0.3.0

func (q QuerySource) Peek(key string) ([]string, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL