binding

package
v0.0.0-...-f2b76e9 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
)

Variables

View Source
var (
	JSON          = jsonBinding{}
	XML           = xmlBinding{}
	Form          = formBinding{}
	FormPost      = formBinding{}
	FormMultipart = formMultipartBinding{}
	Query         = queryBinding{}
	Header        = headerBinding{}
	Uri           = uriBinding{}
)

Functions

func MapForm

func MapForm(obj interface{}, form map[string][]string,
	formfile map[string][]*multipart.FileHeader, tag string) error

MapForm map form or multipart.FileHeader to target obj support map[string]string, map[string][]string, struct struct field指针超过一层没有意义, 不支持

func NewvVlidatorV10

func NewvVlidatorV10() *validatorV10

func SetMultipartMemory

func SetMultipartMemory(n int64)

Types

type Bindinger

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

func NewBindinger

func NewBindinger(method, contentType string) Bindinger

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

type StructValidater

type StructValidater interface {
	ValidateStruct(interface{}) error

	// Engine returns the underlying validator engine which powers the
	// StructValidator implementation.
	Engine() interface{}

	Name() string
}

StructValidater is an interface which needs to be implemented

var Validator StructValidater = NewvVlidatorV10()

Validator is the default validator which implements the StructValidator interface. It uses https://github.com/go-playground/validator/tree/v10.5.0

Jump to

Keyboard shortcuts

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