binding

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBindingConfig

func ApplyBindingConfig(cfg Config)

func BindJSON

func BindJSON[T any](c *gin.Context) (T, error)

func BindPath

func BindPath[T any](c *gin.Context) (T, error)

func BindQuery

func BindQuery[T any](c *gin.Context) (T, error)

func RegisterValidation

func RegisterValidation(tag string, fn validator.Func) error

Types

type BindError

type BindError struct {
	Source  BindSource
	Kind    BindErrorKind
	Message string
	Fields  []FieldViolation
	Cause   error
}

func (*BindError) Error

func (e *BindError) Error() string

func (*BindError) Unwrap

func (e *BindError) Unwrap() error

type BindErrorKind

type BindErrorKind string
const (
	BindErrorMalformedBody   BindErrorKind = "malformed_body"
	BindErrorValidation      BindErrorKind = "validation"
	BindErrorUnsupportedType BindErrorKind = "unsupported_type"
	BindErrorInvalidParams   BindErrorKind = "invalid_params"
)

type BindSource

type BindSource string
const (
	BindSourceJSON  BindSource = "json"
	BindSourcePath  BindSource = "path"
	BindSourceQuery BindSource = "query"
)

type Config

type Config struct {
	DisallowUnknownFields bool `yaml:"disallow-unknown-fields"`
	UseNumber             bool `yaml:"use-number"`
}

func DefaultConfig

func DefaultConfig() Config

type FieldViolation

type FieldViolation struct {
	Field   string
	Rule    string
	Param   string
	Message string
}

Jump to

Keyboard shortcuts

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