Documentation
¶
Index ¶
- Constants
- Variables
- func BindForm(req *http.Request, target interface{}) error
- func BindRequestBody(r *http.Request, v interface{}, opts ...OptionFunc) error
- func BindRequestQuery(r *http.Request, v interface{}) error
- func BindRequestVars(r *http.Request, raws map[string]string, v interface{}) error
- func BindURLValues(vars url.Values, target interface{}) error
- func CodecForRequest(r *http.Request, name string, opt Options) (encoding.Codec, bool)
- func ContentSubtype(contentType string) string
- func ContentType(subtype string) string
- func EncodeURL(pathTemplate string, msg interface{}, needQuery bool) string
- func TryMyBestBind(r *http.Request, v interface{}, opts ...OptionFunc)
- type OptionFunc
- type Options
Constants ¶
const (
MegaByte16 = 16 * 1024 * 1024
)
Variables ¶
var (
ErrBind = fmt.Errorf("bind error")
)
Functions ¶
func BindRequestBody ¶
func BindRequestBody(r *http.Request, v interface{}, opts ...OptionFunc) error
BindRequestBody decodes the request body to object.
func BindRequestQuery ¶
BindRequestQuery decodes the request vars to object.
func BindRequestVars ¶
BindRequestVars decodes the request vars to object.
func BindURLValues ¶ added in v0.0.5
BindURLValues bind vars parameters to target.
func CodecForRequest ¶
CodecForRequest get encoding.Codec via http.Request
func ContentSubtype ¶
ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with but no content-subtype will be returned. according rfc7231. contentType is assumed to be lowercase already.
func ContentType ¶
ContentType returns the content-type with base prefix.
func TryMyBestBind ¶ added in v0.0.2
func TryMyBestBind(r *http.Request, v interface{}, opts ...OptionFunc)
TryMyBestBind decodes the request to object. 不支持解析 multipart/form-data , 需要解析大文件数据请使用 BindForm 只有 MegaByte16 以下的内容才能被 form-data 解析
Types ¶
type OptionFunc ¶
type OptionFunc func(*Options)
func WithDefaultCodec ¶
func WithDefaultCodec(codec string) OptionFunc
WithDefaultCodec set default codec.