Documentation ¶
Index ¶
- Variables
- func BytesList(ss ...string) (dataList [][]byte)
- func CloneRequestBody(req *http.Request) ([]byte, error)
- func ContentMarshal(rv reflect.Value, in string, format string) (dataList [][]byte, err error)
- func ContentUnmarshal(rv reflect.Value, tpe reflect.Type, in string, name string, format string, ...) error
- func GetStructFieldDisplayName(field *reflect.StructField) string
- func GetTagDefault(field *reflect.StructField) (string, bool)
- func GetTagErrMsg(field *reflect.StructField) (string, bool)
- func GetTagIn(field *reflect.StructField) (tagIn string, hasIn bool, tagInFlags map[string]bool)
- func GetTagValidate(field *reflect.StructField) (string, bool)
- func LocateJSONPath(data []byte, offset int64) string
- func MarshalAndValidate(rv reflect.Value, tpe reflect.Type, defaultValue string, isRequired bool, ...) string
- func MarshalParameters(group *ParameterGroup, getter IParameterValuesGetter) error
- func MustStructValue(functionName string, rv reflect.Value)
- func NewFileHeader(fieldName string, filename string, content []byte) (fileHeader *multipart.FileHeader, err error)
- func NewHttpRequestFromParameterGroup(method string, uri string, m *ParameterGroup, metadatas ...courier.Metadata) (req *http.Request, err error)
- func NewRequest(method string, uri string, v interface{}, metadatas ...courier.Metadata) (*http.Request, error)
- func RegisterContentTransformer(contentTransformer *ContentTransformer)
- func ResolveCommaSplitValues(tpe reflect.Type, ss ...string) (values []string)
- func Stringify(v interface{}) ([]byte, error)
- func Unquote(data []byte, err error) ([]byte, error)
- type ContentTransformer
- type ErrMsgMap
- type IParameterValuesGetter
- type ParameterErrors
- type ParameterGroup
- type ParameterMap
- type ParameterMeta
- func (p *ParameterMeta) IsExplode() bool
- func (p *ParameterMeta) IsMultipart() bool
- func (p *ParameterMeta) Marshal() (dataList [][]byte, err error)
- func (p *ParameterMeta) Unmarshal(datalist ...[]byte) error
- func (p *ParameterMeta) UnmarshalAndValidate(dataList ...[]byte) error
- func (p *ParameterMeta) UnmarshalFromReader(reader io.Reader) error
- func (p *ParameterMeta) UnmarshalStringAndValidate(ss ...string) error
- func (p *ParameterMeta) Validate() (bool, status_error.ErrorFields)
- type ParameterValuesGetter
- func (getter *ParameterValuesGetter) Body() io.Reader
- func (getter *ParameterValuesGetter) Cookie(name string) []string
- func (getter *ParameterValuesGetter) FormFile(name string) ([]*multipart.FileHeader, error)
- func (getter *ParameterValuesGetter) FormValue(name string) []string
- func (getter *ParameterValuesGetter) Header(name string) []string
- func (getter *ParameterValuesGetter) Initial() error
- func (getter *ParameterValuesGetter) Param(name string) string
- func (getter *ParameterValuesGetter) Query(name string) []string
- type PathWalker
- type Scanner
- type TagFlags
- func GetParameterDisplayName(field *reflect.StructField) (string, TagFlags)
- func GetTagFmt(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
- func GetTagJSON(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
- func GetTagName(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
- func GetTagStyle(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
- func GetTagValueAndFlags(tagString string) (v string, tagFlags TagFlags)
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMsgForRequired = "缺失必填字段"
Functions ¶
func ContentMarshal ¶
func ContentUnmarshal ¶
func GetStructFieldDisplayName ¶
func GetStructFieldDisplayName(field *reflect.StructField) string
func GetTagDefault ¶
func GetTagDefault(field *reflect.StructField) (string, bool)
func GetTagErrMsg ¶
func GetTagErrMsg(field *reflect.StructField) (string, bool)
func GetTagValidate ¶
func GetTagValidate(field *reflect.StructField) (string, bool)
func LocateJSONPath ¶
func MarshalAndValidate ¶
func MarshalParameters ¶
func MarshalParameters(group *ParameterGroup, getter IParameterValuesGetter) error
func MustStructValue ¶
func NewFileHeader ¶
func NewRequest ¶
func RegisterContentTransformer ¶
func RegisterContentTransformer(contentTransformer *ContentTransformer)
func ResolveCommaSplitValues ¶
Types ¶
type ContentTransformer ¶
type ContentTransformer struct { Key string ContentType string Marshal func(v interface{}) ([]byte, error) Unmarshal func(data []byte, v interface{}) error }
func GetContentTransformer ¶
func GetContentTransformer(keyOrContentType string) *ContentTransformer
type ErrMsgMap ¶
func (ErrMsgMap) ErrorFieldsIn ¶
func (errMsgMap ErrMsgMap) ErrorFieldsIn(in string, parentField string) (errFields status_error.ErrorFields)
type IParameterValuesGetter ¶
type ParameterErrors ¶
type ParameterErrors struct {
StatusError *status_error.StatusError
}
func (*ParameterErrors) Err ¶
func (p *ParameterErrors) Err() error
func (*ParameterErrors) Merge ¶
func (p *ParameterErrors) Merge(err error)
type ParameterGroup ¶
type ParameterGroup struct { Parameters ParameterMap Context ParameterMap FormData ParameterMap Body *ParameterMeta Value reflect.Value }
func ParameterGroupFromReflectValue ¶
func ParameterGroupFromReflectValue(rv reflect.Value) (group *ParameterGroup)
func ParameterGroupFromValue ¶
func ParameterGroupFromValue(v interface{}) (m *ParameterGroup)
func (*ParameterGroup) Scan ¶
func (m *ParameterGroup) Scan()
func (*ParameterGroup) ValidateNoBodyByHook ¶
func (m *ParameterGroup) ValidateNoBodyByHook() (bool, status_error.ErrorFields)
type ParameterMap ¶
type ParameterMap map[string]*ParameterMeta
func (ParameterMap) Add ¶
func (m ParameterMap) Add(parameterMeta *ParameterMeta)
func (ParameterMap) Get ¶
func (m ParameterMap) Get(fieldName string) (rv *ParameterMeta, ok bool)
func (ParameterMap) Len ¶
func (m ParameterMap) Len() int
func (ParameterMap) List ¶
func (m ParameterMap) List() (list []*ParameterMeta)
type ParameterMeta ¶
type ParameterMeta struct { Name string In string Format string InFlags TagFlags Field *reflect.StructField Value reflect.Value Style string StyleFlags TagFlags DefaultValue string Required bool TagValidate string TagErrMsg string }
func NewParameterMeta ¶
func NewParameterMeta(field *reflect.StructField, rv reflect.Value, tagIn string, tagInFlags TagFlags) *ParameterMeta
func (*ParameterMeta) IsExplode ¶
func (p *ParameterMeta) IsExplode() bool
func (*ParameterMeta) IsMultipart ¶
func (p *ParameterMeta) IsMultipart() bool
func (*ParameterMeta) Marshal ¶
func (p *ParameterMeta) Marshal() (dataList [][]byte, err error)
func (*ParameterMeta) Unmarshal ¶
func (p *ParameterMeta) Unmarshal(datalist ...[]byte) error
func (*ParameterMeta) UnmarshalAndValidate ¶
func (p *ParameterMeta) UnmarshalAndValidate(dataList ...[]byte) error
func (*ParameterMeta) UnmarshalFromReader ¶
func (p *ParameterMeta) UnmarshalFromReader(reader io.Reader) error
for body
func (*ParameterMeta) UnmarshalStringAndValidate ¶
func (p *ParameterMeta) UnmarshalStringAndValidate(ss ...string) error
for parameter
func (*ParameterMeta) Validate ¶
func (p *ParameterMeta) Validate() (bool, status_error.ErrorFields)
type ParameterValuesGetter ¶
type ParameterValuesGetter struct { Request *http.Request // contains filtered or unexported fields }
func NewParameterValuesGetter ¶
func NewParameterValuesGetter(r *http.Request) *ParameterValuesGetter
func (*ParameterValuesGetter) Body ¶
func (getter *ParameterValuesGetter) Body() io.Reader
func (*ParameterValuesGetter) Cookie ¶
func (getter *ParameterValuesGetter) Cookie(name string) []string
func (*ParameterValuesGetter) FormFile ¶
func (getter *ParameterValuesGetter) FormFile(name string) ([]*multipart.FileHeader, error)
func (*ParameterValuesGetter) FormValue ¶
func (getter *ParameterValuesGetter) FormValue(name string) []string
func (*ParameterValuesGetter) Header ¶
func (getter *ParameterValuesGetter) Header(name string) []string
func (*ParameterValuesGetter) Initial ¶
func (getter *ParameterValuesGetter) Initial() error
func (*ParameterValuesGetter) Param ¶
func (getter *ParameterValuesGetter) Param(name string) string
func (*ParameterValuesGetter) Query ¶
func (getter *ParameterValuesGetter) Query(name string) []string
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 Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func NewScanner() *Scanner
type TagFlags ¶
func GetParameterDisplayName ¶
func GetParameterDisplayName(field *reflect.StructField) (string, TagFlags)
func GetTagFmt ¶
func GetTagFmt(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
func GetTagJSON ¶
func GetTagJSON(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
func GetTagName ¶
func GetTagName(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
func GetTagStyle ¶
func GetTagStyle(field *reflect.StructField) (name string, exists bool, tagFlags TagFlags)
func GetTagValueAndFlags ¶
Click to show internal directories.
Click to hide internal directories.