bind

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binder

type Binder struct {
	// contains filtered or unexported fields
}

Binder populates struct fields from path, query, header, and default sources.

func New

func New() *Binder

New creates an empty Binder.

func (*Binder) Bind

func (b *Binder) Bind(target any) error

Bind populates struct fields from all registered sources, then applies defaults.

func (*Binder) BindJSON

func (b *Binder) BindJSON(target any, data []byte) error

BindJSON unmarshals data into the struct field tagged with body:"json".

func (*Binder) FromFunc

func (b *Binder) FromFunc(tag string, fn SourceFunc) *Binder

FromFunc adds a custom source with the given tag name.

func (*Binder) FromHeader

func (b *Binder) FromHeader(r *http.Request) *Binder

FromHeader adds an HTTP header source.

func (*Binder) FromPath

func (b *Binder) FromPath(fn SourceFunc) *Binder

FromPath adds a path parameter source.

func (*Binder) FromQuery

func (b *Binder) FromQuery(r *http.Request) *Binder

FromQuery adds a query parameter source using the request URL query.

type SourceFunc

type SourceFunc func(key string) string

SourceFunc extracts a string value by key from a request source.

Jump to

Keyboard shortcuts

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