Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotJSON = errors.New("Not json data")
var ErrNotXML = errors.New("Not xml data")
var ErrNotYAML = errors.New("Not yaml data")
var ErrUnsupported = errors.New("Encode:Unsupported type")
ErrUnsupported Unsupported type error returned
Functions ¶
Types ¶
type Adder ¶
type Adder interface { Add(key string, v reflect.Value, sf reflect.StructField) error Name() string }
Adder interface
type BodyEncode ¶
type BodyEncode struct {
// contains filtered or unexported fields
}
BodyEncode body encoder structure
func NewBodyEncode ¶
func NewBodyEncode(obj interface{}) *BodyEncode
NewBodyEncode create a new body encoder
func (*BodyEncode) Encode ¶
func (b *BodyEncode) Encode(w io.Writer) error
Encode Add Encoder core function, used to set io.Writer into the http body
func (*BodyEncode) Name ¶ added in v0.0.3
func (b *BodyEncode) Name() string
Name http body Encoder name
type FormEncode ¶
FormEncode form-data encoder structure
func NewFormEncode ¶
func NewFormEncode(b *bytes.Buffer) *FormEncode
NewFormEncode create a new form-data encoder
func (*FormEncode) Add ¶
func (f *FormEncode) Add(key string, v reflect.Value, sf reflect.StructField) (err error)
Add Encoder core function, used to set each key / value into the http form-data
func (*FormEncode) CreateFormFile ¶ added in v0.0.5
func (f *FormEncode) CreateFormFile(fieldName, fileName, contentType string) (io.Writer, error)
CreateFormFile 重写原来net/http里面的CreateFormFile函数
type HeaderEncode ¶
type HeaderEncode struct {
// contains filtered or unexported fields
}
HeaderEncode http header encoder structure
func NewHeaderEncode ¶
func NewHeaderEncode(req *http.Request) *HeaderEncode
NewHeaderEncode create a new http header encoder
func (*HeaderEncode) Add ¶
func (h *HeaderEncode) Add(key string, v reflect.Value, sf reflect.StructField) error
Add Encoder core function, used to set each key / value into the http header
type JSONEncode ¶ added in v0.0.2
type JSONEncode struct {
// contains filtered or unexported fields
}
JSONEncode json encoder structure
func NewJSONEncode ¶ added in v0.0.2
func NewJSONEncode(obj interface{}) *JSONEncode
NewJSONEncode create a new json encoder
type QueryEncode ¶
type QueryEncode struct {
// contains filtered or unexported fields
}
QueryEncode URL query encoder structure
func NewQueryEncode ¶
func NewQueryEncode(req *http.Request) *QueryEncode
NewQueryEncode create a new URL query encoder
func (*QueryEncode) Add ¶
func (q *QueryEncode) Add(key string, v reflect.Value, sf reflect.StructField) error
Add Encoder core function, used to set each key / value into the http URL query
func (*QueryEncode) End ¶
func (q *QueryEncode) End() string
End URL query structured data into strings
type WWWFormEncode ¶ added in v0.0.3
type WWWFormEncode struct {
// contains filtered or unexported fields
}
WWWFormEncode x-www-form-urlencoded encoder structure
func NewWWWFormEncode ¶ added in v0.0.3
func NewWWWFormEncode() *WWWFormEncode
NewWWWFormEncode create a new x-www-form-urlencoded encoder
func (*WWWFormEncode) Add ¶ added in v0.0.3
func (we *WWWFormEncode) Add(key string, v reflect.Value, sf reflect.StructField) error
Add Encoder core function, used to set each key / value into the http x-www-form-urlencoded 这里value的设置暴露 reflect.Value和 reflect.StructField原因如下 reflect.Value把value转成字符串 reflect.StructField主要是可以在Add函数里面获取tag相关信息
func (*WWWFormEncode) Encode ¶ added in v0.0.3
func (we *WWWFormEncode) Encode(obj interface{}) (err error)
Encode x-www-form-urlencoded encoder
func (*WWWFormEncode) Name ¶ added in v0.0.3
func (we *WWWFormEncode) Name() string
Name x-www-form-urlencoded Encoder name
type XMLEncode ¶ added in v0.0.2
type XMLEncode struct {
// contains filtered or unexported fields
}
XMLEncode xml encoder structure
func NewXMLEncode ¶ added in v0.0.2
func NewXMLEncode(obj interface{}) *XMLEncode
NewXMLEncode create a new xml encoder
type YAMLEncode ¶ added in v0.0.2
type YAMLEncode struct {
// contains filtered or unexported fields
}
YAMLEncode yaml encoder structure
func NewYAMLEncode ¶ added in v0.0.2
func NewYAMLEncode(obj interface{}) *YAMLEncode
NewYAMLEncode create a new yaml encoder