binding

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnparsable = errors.New("unparsable value")

Functions

func GetParamValue

func GetParamValue(p ParamFieldInfo, ctx core.Context, cookies map[string]*http.Cookie) string

func HasMultipartFields

func HasMultipartFields(t reflect.Type) bool

func IsMultipartFormFilesType

func IsMultipartFormFilesType(t reflect.Type) bool

func ParseDeepObjectQuery

func ParseDeepObjectQuery(query url.Values, name string) map[string]string

func ParseInto

func ParseInto(ctx core.Context, f reflect.Value, value string, preSplit []string, p ParamFieldInfo, parsedQuery ...url.Values) (any, error)

func SetDeepObjectValue

func SetDeepObjectValue(pb *core.PathBuffer, res *core.ValidateResult, f reflect.Value, data map[string]string) map[string]any

func SetupMultipartRequestBody

func SetupMultipartRequestBody(op *core.Operation, fields []MultipartFieldInfo)

func WriteHeader

func WriteHeader(write func(string, string), info *HeaderInfo, f reflect.Value)

func WriteResponse

func WriteResponse(api core.API, ctx core.Context, status int, ct string, body any) error

func WriteResponseWithPanic

func WriteResponseWithPanic(api core.API, ctx core.Context, status int, ct string, body any)

Types

type BodyProcessingConfig

type BodyProcessingConfig struct {
	Body           []byte
	Op             core.Operation
	Value          reflect.Value
	HasInputBody   bool
	InputBodyIndex []int
	Unmarshaler    IntoUnmarshaler
	Validator      func(data any, res *core.ValidateResult)
	Defaults       *FindResult[any]
	Result         *core.ValidateResult
}

type ContextError

type ContextError struct {
	Code int
	Msg  string
	Errs []error
}

func ProcessMultipartForm

func ProcessMultipartForm(ctx core.Context, cfg MultipartProcessingConfig) *ContextError

func ProcessRegularMsgBody

func ProcessRegularMsgBody(cfg BodyProcessingConfig) (int, *ContextError)

func ReadBody

func ReadBody(buf io.Writer, ctx core.Context, maxBytes int64) *ContextError

func (*ContextError) Error

func (e *ContextError) Error() string

type FindResult

type FindResult[T comparable] struct {
	Paths []FindResultPath[T]
}

func (*FindResult[T]) Every

func (r *FindResult[T]) Every(v reflect.Value, f func(reflect.Value, T))

func (*FindResult[T]) EveryPB

func (r *FindResult[T]) EveryPB(pb *core.PathBuffer, v reflect.Value, f func(reflect.Value, T))

type FindResultPath

type FindResultPath[T comparable] struct {
	Path  []int
	Value T
}

type HeaderInfo

type HeaderInfo struct {
	Field      reflect.StructField
	Name       string
	TimeFormat string
}

type InputMeta

type InputMeta struct {
	Params             *FindResult[*ParamFieldInfo]
	InputBodyIndex     []int
	HasInputBody       bool
	RawBodyIndex       []int
	InSchema           *core.Schema
	Resolvers          *FindResult[bool]
	Defaults           *FindResult[any]
	MultipartFields    []MultipartFieldInfo
	MultipartBodyIndex []int
}

func AnalyzeInput

func AnalyzeInput[I any](op *core.Operation, registry core.Registry, fieldsOptionalByDefault bool) *InputMeta

type IntoUnmarshaler

type IntoUnmarshaler = func(data []byte, v any) error

type MultipartFieldInfo

type MultipartFieldInfo struct {
	Name    string
	Index   []int
	IsFile  bool
	IsSlice bool
	Type    reflect.Type
}

func AnalyzeMultipartFields

func AnalyzeMultipartFields(t reflect.Type) []MultipartFieldInfo

type MultipartFormFiles

type MultipartFormFiles[T any] struct {
	// contains filtered or unexported fields
}

func (*MultipartFormFiles[T]) Data

func (m *MultipartFormFiles[T]) Data() T

type MultipartProcessingConfig

type MultipartProcessingConfig struct {
	Value  reflect.Value
	Fields []MultipartFieldInfo
}

type OutputMeta

type OutputMeta struct {
	Headers     *FindResult[*HeaderInfo]
	StatusIndex int
	BodyIndex   int
	BodyFunc    bool
}

func AnalyzeOutput

func AnalyzeOutput[O any](op *core.Operation, registry core.Registry) *OutputMeta

type ParamFieldInfo

type ParamFieldInfo struct {
	Type       reflect.Type
	Name       string
	Loc        string
	Required   bool
	Default    string
	TimeFormat string
	Explode    bool
	Style      string
	Schema     *core.Schema
	IsPointer  bool // true when the original field is a pointer type (#393)
}

type ParamLocation

type ParamLocation struct {
	Explode *bool
	PFI     *ParamFieldInfo
}

type ParamReactor

type ParamReactor interface {
	OnParamSet(isSet bool, parsed any)
}

type ParamWrapper

type ParamWrapper interface {
	Receiver() reflect.Value
}

Jump to

Keyboard shortcuts

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