bind

package
v0.0.0-...-7846ce2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRequest     = errors.New("bind: request is nil")
	ErrNilDestination = errors.New("bind: destination is nil")
	ErrNotAPointer    = errors.New("bind: destination must be a pointer")
	ErrNotAStruct     = errors.New("bind: destination must be a struct")
	ErrExpectedStruct = errors.New("bind: expected struct")
	ErrMultipleTags   = errors.New("bind: multiple tags")
	ErrEmptyTag       = errors.New("bind: tag is empty")
)

Functions

func Bind

func Bind[T any](r *http.Request, dst *T, opts ...Opt) error

Types

type Error

type Error struct {
	Field string // struct field name
	Err   error  // underlying error (conversion, missing tag, etc.)
}

Error represents a failure to bind a single struct field.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type Errors

type Errors struct {
	Errors []Error
}

Errors aggregate one or more BindError values. It implements the error interface.

func (*Errors) Append

func (es *Errors) Append(err Error)

func (*Errors) Error

func (es *Errors) Error() string

Error returns a human‑readable summary.

func (*Errors) Unwrap

func (es *Errors) Unwrap() []error

Unwrap enables errors.Is / errors.As to work on individual errors.

type Opt

type Opt interface {
	BindOpt()
}

Opt is a functional option that configures the binder.

func WithMaxFormMemoryMB

func WithMaxFormMemoryMB(maxFormMemoryMB int64) Opt

func WithPathValueFunc

func WithPathValueFunc(fn func(r *http.Request, name string) string) Opt

func WithValidator

func WithValidator(v *validator.Validate) Opt

Jump to

Keyboard shortcuts

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