bind

package
v0.0.0-...-82862be Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSON = JsonBind{}
View Source
var StrictMatching = false

StrictMatching 严格匹配每一个字段,如果json数据里有绑定对象里没有的字段会报错,表示严格匹配 如果存在报错 json: unknown field xxx 打开json的DisallowUnknownFields

View Source
var UseNumber = false

UseNumber 对于需要转换为 map[string]any 解码器会将数字反编为float64 UseNumber 后将会是一个json.Number对象

如果输入的数字比较大,这个表示会有损精度。所以可以 UseNumber() 启用 json.Number 来用字符串表示数字

View Source
var XML = XmlBind{}

Functions

func DisableBindValidation

func DisableBindValidation()

func DisableDecoderUseNumber

func DisableDecoderUseNumber()

func DisableStrictMatching

func DisableStrictMatching()

func EnableDecoderUseNumber

func EnableDecoderUseNumber()

func EnableStrictMatching

func EnableStrictMatching()

Types

type Bind

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

type JsonBind

type JsonBind struct {
}

func (JsonBind) Bind

func (bind JsonBind) Bind(req *http.Request, data any) error

func (JsonBind) Name

func (bind JsonBind) Name() string

type SliceValidationError

type SliceValidationError []error

func (SliceValidationError) Error

func (err SliceValidationError) Error() string

记录错误栈

type StructValidator

type StructValidator interface {
	Validate(any) error
}
var Validator StructValidator = &defaultValidator{}

type XmlBind

type XmlBind struct {
}

func (XmlBind) Bind

func (bind XmlBind) Bind(req *http.Request, data any) error

func (XmlBind) Name

func (bind XmlBind) Name() string

Jump to

Keyboard shortcuts

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