binding

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSON          = jsonBinding{}
	XML           = xmlBinding{}
	Query         = queryBinding{}
	FormPost      = formPostBinding{}
	FormMultipart = formMultipartBinding{}
	Uri           = uriBinding{}
	ProtoBuf      = protobufBinding{}
	MsgPack       = msgpackBinding{}
	YAML          = yamlBinding{}
	Header        = headerBinding{}
)

Functions

func Bind added in v1.5.11

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

func BindJSON added in v1.5.11

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

BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON).

func BindQuery added in v1.5.11

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

BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).

func BindUri added in v1.5.11

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 BindXML added in v1.5.11

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

BindXML is a shortcut for c.MustBindWith(obj, binding.BindXML).

func BindYAML added in v1.5.11

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

BindYAML is a shortcut for c.MustBindWith(obj, binding.YAML).

func MustBindWith added in v1.5.11

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 added in v1.5.11

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

func ShouldBind added in v1.5.11

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 ShouldBindJSON added in v1.5.11

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

ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).

func ShouldBindQuery added in v1.5.11

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

ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).

func ShouldBindUri added in v1.5.11

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

ShouldBindUri binds the passed struct pointer using the specified binding engine.

func ShouldBindWith added in v1.5.11

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.

func ShouldBindXML added in v1.5.11

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

ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).

func ShouldBindYAML added in v1.5.11

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

ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).

Types

type Binding

type Binding interface {
	Name() string

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

func Body added in v1.5.11

func Body(contentType []byte) Binding

func Default

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

type BindingBody

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

Jump to

Keyboard shortcuts

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