reflectd

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package reflectd provides configurable HTTP form body to struct decoder that depends on Gorilla's schema reflection package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder provides configurable HTTP form body decoding that depends on Gorilla's schema reflection package.

func NewDecoder

func NewDecoder(withOptions ...Option) (_ *Decoder, err error)

func (*Decoder) Decode

func (d *Decoder) Decode(v any, r *http.Request) (err error)

func (*Decoder) DecodeJSON added in v0.1.0

func (d *Decoder) DecodeJSON(v any, r *http.Request) (err error)

func (*Decoder) DecodeMultiPart added in v0.1.0

func (d *Decoder) DecodeMultiPart(v any, r *http.Request, boundary string) (err error)

func (*Decoder) DecodeURLEncoded added in v0.1.0

func (d *Decoder) DecodeURLEncoded(v any, r *http.Request) (err error)

type Option

type Option func(*options) error

Option configures new [Decoder]s.

func WithCookieValues added in v0.0.6

func WithCookieValues(names ...string) Option

WithCookieValues adds a [CookieValueExtractor] to a Decoder.

func WithDefaultMemoryLimitOfOneThirdOfReadLimit

func WithDefaultMemoryLimitOfOneThirdOfReadLimit() Option

WithDefaultMemoryLimitOfOneThirdOfReadLimit contrains memory limit to one third of the read limit when WithMemoryLimit option is not used. Use WithReadLimit option to adjust the read limit.

func WithDefaultReadLimitOf10MB

func WithDefaultReadLimitOf10MB() Option

WithDefaultReadLimitOf10MB enforces the standard library convention when WithReadLimit is not used.

func WithExtractors

func WithExtractors(exs ...extract.RequestValueExtractor) Option

WithExtractors adds [extract.RequestValueExtractor]s to a Decoder. The order of extractors determines their precedence.

func WithHeaderValues

func WithHeaderValues(names ...string) Option

WithHeaderValues adds a [HeaderValueExtractor] to a Decoder.

func WithMemoryLimit

func WithMemoryLimit(upto int64) Option

WithMemoryLimit constrains system memory usage when decoding mixed multipart forms, which typically include file uploads. When the memory limit is exceeded, the excess data is written to disk. Higher limit speeds up handling file uploads.

func WithOptions

func WithOptions(withOptions ...Option) Option

WithOptions combines several [Option]s into one.

func WithPathValues

func WithPathValues(names ...string) Option

WithPathValues adds a [PathValueExtractor] to a Decoder.

func WithQueryValues

func WithQueryValues(names ...string) Option

WithQueryValues adds a [QueryValueExtractor] to a Decoder.

func WithReadLimit

func WithReadLimit(upto int64) Option

WithReadLimit contrains acceptable [request.Body] size.

func WithSessionValues added in v0.0.14

func WithSessionValues(keys ...string) Option

WithSessionValues adds a extract.SessionValueExtractor to a Decoder.

Directories

Path Synopsis
Package schema fills a struct with form values.
Package schema fills a struct with form values.

Jump to

Keyboard shortcuts

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