binding

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEMultipartPOSTForm = "multipart/form-data"
)

Content-Type MIME of the most common data formats.

Variables

View Source
var (
	JSON          = jsonBinding{}
	Form          = formBinding{}
	Query         = queryBinding{}
	FormMultipart = formMultipartBinding{}
	Header        = headerBinding{}
)

These implement the Binding interface and can be used to bind the data present in the request to struct instances.

Functions

This section is empty.

Types

type Binding

type Binding interface {
	Name() string
	Bind(*http.Request, any) error
}

Binding describes the interface which needs to be implemented for binding the data present in the request such as JSON request body, query parameters or the form POST.

func Default

func Default(method, contentType string) Binding

Default returns the appropriate Binding instance based on the HTTP method and the content type.

type BindingBody

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

BindingBody adds BindBody method to Binding. BindBody is similar with Bind, but it reads the body from supplied bytes instead of req.Body.

type BindingUri

type BindingUri interface {
	Name() string
	BindUri(map[string][]string, any) error
}

BindingUri adds BindUri method to Binding. BindUri is similar with Bind, but it reads the Params.

Jump to

Keyboard shortcuts

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