body

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Package body resolves whole or named request bodies to planned Go types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MultipartValue added in v0.3.0

func MultipartValue(form *multipart.Form, target reflect.Type, name string) (any, bool)

func NewEmptyRecord added in v0.4.0

func NewEmptyRecord(target reflect.Type) (any, error)

NewEmptyRecord allocates a detached direct *struct and initializes native original-presence holders without marking any business field as supplied. Callers normalizing typed input must independently prove explicit presence.

Types

type Decoder added in v0.3.0

type Decoder interface{ Decode([]byte, any) error }

Decoder unmarshals a body value into a typed target.

type DecoderFunc added in v0.3.0

type DecoderFunc func([]byte, any) error

func (DecoderFunc) Decode added in v0.3.0

func (f DecoderFunc) Decode(raw []byte, target any) error

type DecoderRegistry added in v0.3.0

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

func NewDecoderRegistry added in v0.3.0

func NewDecoderRegistry() *DecoderRegistry

func (*DecoderRegistry) Lookup added in v0.3.0

func (r *DecoderRegistry) Lookup(mediaType string) (Decoder, bool)

func (*DecoderRegistry) Register added in v0.3.0

func (r *DecoderRegistry) Register(mediaType string, decoder Decoder)

type FieldDecoder added in v0.3.0

type FieldDecoder interface {
	Decoder
	DecodeField([]byte, string, any) (bool, error)
}

type Option

type Option func(*Source)

func WithDecoders added in v0.3.0

func WithDecoders(decoders *DecoderRegistry) Option

func WithExactFieldNames

func WithExactFieldNames() Option

func WithMultipartForm added in v0.3.0

func WithMultipartForm(form *multipart.Form) Option

WithMultipartForm supplies a transport-owned parsed form. The transport retains responsibility for removing any temporary files after the invocation.

type Source

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

func New

func New(raw []byte, contentType string, aliases map[string]string, options ...Option) (*Source, error)

func NewDeferred added in v0.4.0

func NewDeferred(load func(context.Context) (*Source, error)) *Source

NewDeferred preserves the body provider API while initializing bytes and MIME metadata only when a value or replay source is requested. Initialization errors are retained; decoding still happens independently for each target and field.

func (*Source) CaptureSource

func (s *Source) CaptureSource(ctx context.Context, target reflect.Type, name string) (any, bool, error)

CaptureSource retains the selected JSON bytes before decoding loses omission, null or number precision. Other media keep this provider's normal source-type conversion. ReplayPlan owns selection; the body provider owns JSON extraction.

func (*Source) DefaultCacheable

func (s *Source) DefaultCacheable() bool

func (*Source) Kind

func (s *Source) Kind() string

func (*Source) Locate

func (s *Source) Locate(*structology.State) locator.Locator

func (*Source) Priority

func (s *Source) Priority() int

func (*Source) Value

func (s *Source) Value(ctx context.Context, target reflect.Type, name string) (any, bool, error)

func (*Source) ValueWithBodyNullPolicy added in v0.4.0

func (s *Source) ValueWithBodyNullPolicy(ctx context.Context, target reflect.Type, name, policy string) (any, bool, error)

ValueWithBodyNullPolicy applies only this binding's whole JSON null policy.

Jump to

Keyboard shortcuts

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