Documentation ¶
Overview ¶
Package decoder provides decoders.
Index ¶
- Constants
- func WithContentType[T contentTypeSetter](contentType string) func(T)
- func WithSkipFilled[T skipFilledSetter](skip bool) func(T)
- type FormURL
- type FormURLOptionsFunc
- type JSON
- type JSONOptionsFunc
- type MultipartFile
- type MultipartFiles
- type MultipartFormData
- type MultipartFormDataOptionsFunc
- type XML
- type XMLOptionsFunc
Constants ¶
const ( // ContentTypeFormURL content-type header for url form decoder. ContentTypeFormURL = "application/x-www-form-urlencoded" // SplitSymbol array split symbol. SplitSymbol = "," )
const (
// ContentTypeJSON content-type header for json decoder.
ContentTypeJSON = "application/json"
)
const (
// ContentTypeMultipartFormData content-type header for multipart form-data decoder.
ContentTypeMultipartFormData = "multipart/form-data"
)
const (
// ContentTypeXML content-type header for xml decoder.
ContentTypeXML = "application/xml"
)
Variables ¶
This section is empty.
Functions ¶
func WithContentType ¶
func WithContentType[T contentTypeSetter](contentType string) func(T)
WithContentType sets content type.
func WithSkipFilled ¶ added in v1.7.1
func WithSkipFilled[T skipFilledSetter](skip bool) func(T)
WithSkipFilled sets skip filled.
Types ¶
type FormURL ¶
type FormURL struct {
// contains filtered or unexported fields
}
FormURL url form decoder.
func NewFormURL ¶
func NewFormURL(opts ...FormURLOptionsFunc) *FormURL
NewFormURL returns new url form decoder.
func (*FormURL) ContentType ¶
ContentType returns content-type header value.
func (*FormURL) Decode ¶
Decode decodes url form value from http request into ptr.
ptr must have a type of either struct or map.
func (*FormURL) EnableExperimentalFastStructFieldParser ¶ added in v1.7.0
func (f *FormURL) EnableExperimentalFastStructFieldParser()
EnableExperimentalFastStructFieldParser enables the use of experimental fast struct field parser.
type FormURLOptionsFunc ¶
type FormURLOptionsFunc func(*FormURL)
FormURLOptionsFunc function for setting options.
func WithDisabledSplit ¶
func WithDisabledSplit() FormURLOptionsFunc
WithDisabledSplit disables array splitting.
func WithSplitSymbol ¶
func WithSplitSymbol(splitSymbol string) FormURLOptionsFunc
WithSplitSymbol sets array split symbol.
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON json decoder.
func (*JSON) ContentType ¶
ContentType returns content-type header value.
type JSONOptionsFunc ¶
type JSONOptionsFunc = func(*JSON)
JSONOptionsFunc function for setting xml options.
type MultipartFile ¶
type MultipartFile struct { Key string File multipart.File Header *multipart.FileHeader }
MultipartFile parsed multipart form-data file.
func (*MultipartFile) ContentType ¶
func (f *MultipartFile) ContentType() string
ContentType returns content type of parsed file.
func (*MultipartFile) Copy ¶
func (f *MultipartFile) Copy() (MultipartFile, error)
Copy returns copy of parsed file.
func (*MultipartFile) IsValid ¶ added in v1.7.1
func (f *MultipartFile) IsValid() bool
IsValid returns valid state of parsed file.
type MultipartFiles ¶
type MultipartFiles []MultipartFile
MultipartFiles parsed multipart form-data files.
type MultipartFormData ¶
type MultipartFormData struct {
// contains filtered or unexported fields
}
MultipartFormData multipart form-data decoder.
func NewMultipartFormData ¶
func NewMultipartFormData(opts ...MultipartFormDataOptionsFunc) *MultipartFormData
NewMultipartFormData returns new multipart form-data decoder.
func (*MultipartFormData) ContentType ¶
func (m *MultipartFormData) ContentType() string
ContentType returns content type of url form decoder.
func (*MultipartFormData) Decode ¶
func (m *MultipartFormData) Decode(r *http.Request, ptr any) error
Decode decodes url form value from http request into ptr.
ptr must be pointer to a struct.
func (*MultipartFormData) EnableExperimentalFastStructFieldParser ¶ added in v1.7.0
func (m *MultipartFormData) EnableExperimentalFastStructFieldParser()
EnableExperimentalFastStructFieldParser enables the use of experimental fast struct field parser.
type MultipartFormDataOptionsFunc ¶
type MultipartFormDataOptionsFunc = func(*MultipartFormData)
MultipartFormDataOptionsFunc function for setting options.
func WithMaxMemory ¶
func WithMaxMemory(maxMemory int64) MultipartFormDataOptionsFunc
WithMaxMemory sets max memory.
type XML ¶
type XML struct {
// contains filtered or unexported fields
}
XML xml decoder.
func (*XML) ContentType ¶
ContentType returns content-type header value.
type XMLOptionsFunc ¶
type XMLOptionsFunc = func(*XML)
XMLOptionsFunc function for setting xml options.