Documentation ¶
Index ¶
- Variables
- func ContextWithTransformerMgr(ctx context.Context, mgr TransformerMgr) context.Context
- func EachParameter(ctx context.Context, tpe typesx.Type, each func(p *Parameter) bool)
- func EachRequestParameter(ctx context.Context, tpe typesx.Type, each func(rp *RequestParameter)) error
- func GroupedParametersSetFromContext(ctx context.Context) *sync.Map
- func MIMEHeader(headers ...textproto.MIMEHeader) textproto.MIMEHeader
- func MustNewFileHeader(fieldName string, filename string, r io.Reader) *multipart.FileHeader
- func NewFileHeader(fieldName string, filename string, r io.Reader) (*multipart.FileHeader, error)
- func NewValidator(ctx context.Context, fieldType typex.Type, tags map[string]Tag, omitempty bool, ...) (validator.Validator, error)
- func ParamsFromMap(m map[string]string) httprouter.Params
- func ParseTags(tag string) map[string]Tag
- func WithGroupedParametersSet(ctx context.Context, m *sync.Map) context.Context
- type CanInterface
- type CanNextReader
- type CanNextWriter
- type CanString
- type CommonTransformOption
- type FileHeaderReader
- type FlattenParams
- type FormPartWriter
- type GroupedParameters
- type HeaderWriter
- type MayValidator
- type Parameter
- type ParameterValue
- type PathWalker
- type PathnamePattern
- type RequestParameter
- type StringBuilders
- type StringReader
- type StringReaders
- type Tag
- type Transformer
- type TransformerAndOption
- type TransformerFactory
- type TransformerHTMLText
- func (TransformerHTMLText) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (t *TransformerHTMLText) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerHTMLText) NamedByTag() string
- func (TransformerHTMLText) Names() []string
- func (TransformerHTMLText) New(context.Context, typesutil.Type) (Transformer, error)
- func (t *TransformerHTMLText) String() string
- type TransformerJSON
- func (TransformerJSON) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (transformer *TransformerJSON) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerJSON) NamedByTag() string
- func (TransformerJSON) Names() []string
- func (TransformerJSON) New(context.Context, typesutil.Type) (Transformer, error)
- func (transformer *TransformerJSON) String() string
- type TransformerMgr
- type TransformerMultipart
- func (transformer *TransformerMultipart) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (transformer *TransformerMultipart) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerMultipart) NamedByTag() string
- func (TransformerMultipart) Names() []string
- func (TransformerMultipart) New(ctx context.Context, typ typesutil.Type) (Transformer, error)
- func (transformer *TransformerMultipart) String() string
- type TransformerOctetStream
- func (TransformerOctetStream) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (t *TransformerOctetStream) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerOctetStream) Names() []string
- func (TransformerOctetStream) New(context.Context, typesx.Type) (Transformer, error)
- func (t *TransformerOctetStream) String() string
- type TransformerOption
- type TransformerPlainText
- func (t *TransformerPlainText) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (t *TransformerPlainText) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerPlainText) Names() []string
- func (TransformerPlainText) New(context.Context, typesx.Type) (Transformer, error)
- func (t *TransformerPlainText) String() string
- type TransformerSuper
- type TransformerURLEncoded
- func (transformer *TransformerURLEncoded) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (transformer *TransformerURLEncoded) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (TransformerURLEncoded) NamedByTag() string
- func (TransformerURLEncoded) Names() []string
- func (TransformerURLEncoded) New(ctx context.Context, typ typesutil.Type) (Transformer, error)
- type WithNamedByTag
- type XMLTransformer
- func (XMLTransformer) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, ...) error
- func (t *XMLTransformer) EncodeTo(ctx context.Context, w io.Writer, v interface{}) error
- func (XMLTransformer) NamedByTag() string
- func (XMLTransformer) Names() []string
- func (XMLTransformer) New(context.Context, typesutil.Type) (Transformer, error)
- func (t *XMLTransformer) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var TransformerMgrDefault = &TransformerFactory{}
Functions ¶
func ContextWithTransformerMgr ¶ added in v1.5.0
func ContextWithTransformerMgr(ctx context.Context, mgr TransformerMgr) context.Context
func EachParameter ¶ added in v1.21.0
func EachRequestParameter ¶ added in v1.21.0
func GroupedParametersSetFromContext ¶ added in v1.21.0
func MIMEHeader ¶
func MIMEHeader(headers ...textproto.MIMEHeader) textproto.MIMEHeader
func MustNewFileHeader ¶
func NewFileHeader ¶
func NewValidator ¶
func ParamsFromMap ¶ added in v1.21.0
func ParamsFromMap(m map[string]string) httprouter.Params
Types ¶
type CanInterface ¶ added in v1.21.1
type CanInterface interface {
Interface() interface{}
}
type CanNextReader ¶ added in v1.21.1
type CanNextWriter ¶ added in v1.21.1
type CommonTransformOption ¶
type FileHeaderReader ¶ added in v1.21.0
type FileHeaderReader struct {
// contains filtered or unexported fields
}
func (*FileHeaderReader) Interface ¶ added in v1.21.1
func (f *FileHeaderReader) Interface() interface{}
type FlattenParams ¶
type FlattenParams struct {
Parameters []RequestParameter
}
func (*FlattenParams) CollectParams ¶
func (FlattenParams) NewValidator ¶
func (FlattenParams) String ¶
func (FlattenParams) String() string
func (*FlattenParams) Validate ¶
func (params *FlattenParams) Validate(v interface{}) error
type FormPartWriter ¶ added in v1.21.0
type FormPartWriter struct {
// contains filtered or unexported fields
}
func NewFormPartWriter ¶ added in v1.21.0
func NewFormPartWriter(createPartWriter func(header textproto.MIMEHeader) (io.Writer, error)) *FormPartWriter
func (*FormPartWriter) Header ¶ added in v1.21.0
func (w *FormPartWriter) Header() http.Header
func (*FormPartWriter) NextWriter ¶ added in v1.21.0
func (w *FormPartWriter) NextWriter() io.Writer
type GroupedParameters ¶ added in v1.21.0
func CollectGroupedParameters ¶ added in v1.21.0
func CollectGroupedParameters(ctx context.Context, tpe typesx.Type) GroupedParameters
type HeaderWriter ¶ added in v1.21.0
type HeaderWriter interface { httpx.WithHeader io.Writer }
func WriterWithHeader ¶ added in v1.21.0
func WriterWithHeader(w io.Writer, header http.Header) HeaderWriter
type MayValidator ¶ added in v1.5.0
type Parameter ¶ added in v1.21.0
type ParameterValue ¶ added in v1.21.0
type PathWalker ¶
type PathWalker struct {
// contains filtered or unexported fields
}
func (*PathWalker) Enter ¶
func (pw *PathWalker) Enter(i interface{})
func (*PathWalker) Exit ¶
func (pw *PathWalker) Exit()
func (*PathWalker) Paths ¶
func (pw *PathWalker) Paths() []interface{}
func (*PathWalker) String ¶
func (pw *PathWalker) String() string
type PathnamePattern ¶ added in v1.21.0
type PathnamePattern struct {
// contains filtered or unexported fields
}
func NewPathnamePattern ¶ added in v1.21.0
func NewPathnamePattern(p string) *PathnamePattern
func (*PathnamePattern) Parse ¶ added in v1.21.0
func (pattern *PathnamePattern) Parse(pathname string) (params httprouter.Params, err error)
func (*PathnamePattern) String ¶ added in v1.21.0
func (pattern *PathnamePattern) String() string
func (*PathnamePattern) Stringify ¶ added in v1.21.0
func (pattern *PathnamePattern) Stringify(params httprouter.Params) string
type RequestParameter ¶ added in v1.21.0
type RequestParameter struct { Parameter TransformerOption TransformerOption Transformer Transformer Validator validator.Validator }
type StringBuilders ¶ added in v1.21.0
type StringBuilders struct {
// contains filtered or unexported fields
}
func NewStringBuilders ¶ added in v1.21.0
func NewStringBuilders() *StringBuilders
func (*StringBuilders) NextWriter ¶ added in v1.21.0
func (v *StringBuilders) NextWriter() io.Writer
func (*StringBuilders) SetN ¶ added in v1.21.0
func (v *StringBuilders) SetN(n int)
func (*StringBuilders) StringSlice ¶ added in v1.21.0
func (v *StringBuilders) StringSlice() []string
type StringReader ¶ added in v1.21.1
type StringReader struct {
// contains filtered or unexported fields
}
func NewStringReader ¶ added in v1.21.1
func NewStringReader(v string) *StringReader
func (*StringReader) Interface ¶ added in v1.21.1
func (r *StringReader) Interface() interface{}
func (*StringReader) Read ¶ added in v1.21.1
func (r *StringReader) Read(p []byte) (n int, err error)
func (*StringReader) String ¶ added in v1.21.1
func (r *StringReader) String() string
type StringReaders ¶ added in v1.21.0
type StringReaders struct {
// contains filtered or unexported fields
}
func NewFileHeaderReaders ¶ added in v1.21.0
func NewFileHeaderReaders(fileHeaders []*multipart.FileHeader) *StringReaders
func NewStringReaders ¶ added in v1.21.0
func NewStringReaders(values []string) *StringReaders
func (*StringReaders) Interface ¶ added in v1.21.1
func (v *StringReaders) Interface() interface{}
func (*StringReaders) Len ¶ added in v1.21.0
func (v *StringReaders) Len() int
func (*StringReaders) NextReader ¶ added in v1.21.0
func (v *StringReaders) NextReader() io.Reader
type Transformer ¶
type Transformer interface { // name or alias of transformer // prefer using some keyword about content-type // first must validate content-type Names() []string // create transformer new transformer instance by type // in this step will to check transformer is valid for type New(context.Context, typesx.Type) (Transformer, error) // EncodeTo // if w implement interface { Header() http.Header } // Content-Type will be set EncodeTo(ctx context.Context, w io.Writer, v interface{}) (err error) // DecodeFrom DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error }
func NewTransformer ¶ added in v1.21.0
func NewTransformer(ctx context.Context, tpe typesx.Type, opt TransformerOption) (Transformer, error)
type TransformerAndOption ¶ added in v1.21.0
type TransformerAndOption struct { Transformer Option TransformerOption }
type TransformerFactory ¶
type TransformerFactory struct {
// contains filtered or unexported fields
}
func (*TransformerFactory) NewTransformer ¶
func (c *TransformerFactory) NewTransformer(ctx context.Context, typ typesx.Type, opt TransformerOption) (Transformer, error)
func (*TransformerFactory) Register ¶
func (c *TransformerFactory) Register(transformers ...Transformer)
type TransformerHTMLText ¶ added in v1.21.0
type TransformerHTMLText struct { }
func (TransformerHTMLText) DecodeFrom ¶ added in v1.21.0
func (TransformerHTMLText) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerHTMLText) NamedByTag ¶ added in v1.21.0
func (TransformerHTMLText) NamedByTag() string
func (TransformerHTMLText) Names ¶ added in v1.21.0
func (TransformerHTMLText) Names() []string
func (TransformerHTMLText) New ¶ added in v1.21.0
func (TransformerHTMLText) New(context.Context, typesutil.Type) (Transformer, error)
func (*TransformerHTMLText) String ¶ added in v1.21.0
func (t *TransformerHTMLText) String() string
type TransformerJSON ¶ added in v1.21.0
type TransformerJSON struct { }
func (TransformerJSON) DecodeFrom ¶ added in v1.21.0
func (TransformerJSON) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerJSON) NamedByTag ¶ added in v1.21.0
func (TransformerJSON) NamedByTag() string
func (TransformerJSON) Names ¶ added in v1.21.0
func (TransformerJSON) Names() []string
func (TransformerJSON) New ¶ added in v1.21.0
func (TransformerJSON) New(context.Context, typesutil.Type) (Transformer, error)
func (*TransformerJSON) String ¶ added in v1.21.0
func (transformer *TransformerJSON) String() string
type TransformerMgr ¶
type TransformerMgr interface {
NewTransformer(context.Context, typesx.Type, TransformerOption) (Transformer, error)
}
func TransformerMgrFromContext ¶ added in v1.5.0
func TransformerMgrFromContext(ctx context.Context) TransformerMgr
type TransformerMultipart ¶ added in v1.21.0
type TransformerMultipart struct {
*FlattenParams
}
TransformerMultipart for multipart/form-data
func (*TransformerMultipart) DecodeFrom ¶ added in v1.21.0
func (transformer *TransformerMultipart) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerMultipart) NamedByTag ¶ added in v1.21.0
func (TransformerMultipart) NamedByTag() string
func (TransformerMultipart) Names ¶ added in v1.21.0
func (TransformerMultipart) Names() []string
func (TransformerMultipart) New ¶ added in v1.21.0
func (TransformerMultipart) New(ctx context.Context, typ typesutil.Type) (Transformer, error)
func (*TransformerMultipart) String ¶ added in v1.21.0
func (transformer *TransformerMultipart) String() string
type TransformerOctetStream ¶ added in v1.21.0
type TransformerOctetStream struct { }
func (TransformerOctetStream) DecodeFrom ¶ added in v1.21.0
func (TransformerOctetStream) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerOctetStream) Names ¶ added in v1.21.0
func (TransformerOctetStream) Names() []string
func (TransformerOctetStream) New ¶ added in v1.21.0
func (TransformerOctetStream) New(context.Context, typesx.Type) (Transformer, error)
func (*TransformerOctetStream) String ¶ added in v1.21.0
func (t *TransformerOctetStream) String() string
type TransformerOption ¶
type TransformerOption struct { Name string MIME string CommonTransformOption }
func (TransformerOption) String ¶
func (op TransformerOption) String() string
type TransformerPlainText ¶ added in v1.21.0
type TransformerPlainText struct { }
func (*TransformerPlainText) DecodeFrom ¶ added in v1.21.0
func (t *TransformerPlainText) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerPlainText) Names ¶ added in v1.21.0
func (TransformerPlainText) Names() []string
func (TransformerPlainText) New ¶ added in v1.21.0
func (TransformerPlainText) New(context.Context, typesx.Type) (Transformer, error)
func (*TransformerPlainText) String ¶ added in v1.21.0
func (t *TransformerPlainText) String() string
type TransformerSuper ¶ added in v1.21.1
type TransformerSuper struct { CommonTransformOption // contains filtered or unexported fields }
func NewTransformerSuper ¶ added in v1.21.1
func NewTransformerSuper(transformer Transformer, opt *CommonTransformOption) *TransformerSuper
func (*TransformerSuper) DecodeFrom ¶ added in v1.21.1
type TransformerURLEncoded ¶ added in v1.21.0
type TransformerURLEncoded struct {
*FlattenParams
}
TransformerURLEncoded for application/x-www-form-urlencoded
var s = struct { Username string `name:"username"` Nickname string `name:"username,omitempty"` Tags []string `name:"tag"` }{ Username: "name", Tags: []string{"1","2"}, }
will transform to
username=name&tag=1&tag=2
func (*TransformerURLEncoded) DecodeFrom ¶ added in v1.21.0
func (transformer *TransformerURLEncoded) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (TransformerURLEncoded) NamedByTag ¶ added in v1.21.0
func (TransformerURLEncoded) NamedByTag() string
func (TransformerURLEncoded) Names ¶ added in v1.21.0
func (TransformerURLEncoded) Names() []string
func (TransformerURLEncoded) New ¶ added in v1.21.0
func (TransformerURLEncoded) New(ctx context.Context, typ typesutil.Type) (Transformer, error)
type WithNamedByTag ¶ added in v1.21.0
type WithNamedByTag interface {
NamedByTag() string
}
type XMLTransformer ¶
type XMLTransformer struct { }
func (XMLTransformer) DecodeFrom ¶ added in v1.21.0
func (XMLTransformer) DecodeFrom(ctx context.Context, r io.Reader, v interface{}, headers ...textproto.MIMEHeader) error
func (XMLTransformer) NamedByTag ¶
func (XMLTransformer) NamedByTag() string
func (XMLTransformer) Names ¶
func (XMLTransformer) Names() []string
func (XMLTransformer) New ¶
func (XMLTransformer) New(context.Context, typesutil.Type) (Transformer, error)
func (*XMLTransformer) String ¶
func (t *XMLTransformer) String() string
Source Files ¶
- flatten_params.go
- io.go
- path_walker.go
- pathname_pattern.go
- request_parameter.go
- transformer.go
- transformer_html.go
- transformer_json.go
- transformer_multipart.go
- transformer_octet_stream.go
- transformer_plain_text.go
- transformer_super.go
- transformer_urlencoded.go
- transformer_xml.go
- utils.go
- utils_parameters.go
- validator.go
Click to show internal directories.
Click to hide internal directories.