Documentation
¶
Index ¶
- Constants
- Variables
- func ContentTypeFormat(c string) string
- func Decode(r io.Reader, i any, t any) error
- func Encode(w io.Writer, i any, t any) error
- func Marshal(i any, t any) ([]byte, error)
- func Register(t string, handle Binder) error
- func SetMimeType(id uint8, name string, typ string)
- func Unmarshal(b []byte, i any, t any) error
- type Binder
- type ContentTypeMod
- type T
Constants ¶
View Source
const ( HeaderAccept = "Accept" HeaderContentType = "Content-Type" )
View Source
const ( MIMEJSON string = "application/json" MIMEXML = "application/xml" MIMEXML2 = "text/xml" MIMEPOSTForm = "application/x-www-form-urlencoded" MIMEMultipartPOSTForm = "multipart/form-data" MIMEPROTOBUF = "application/x-protobuf" MIMEMSGPACK = "application/x-msgpack" MIMEMSGPACK2 = "application/msgpack" MIMEYAML = "application/x-yaml" )
Content-Type MIME of the most common data formats.
Variables ¶
View Source
var Form = &formBinding{}
View Source
var Json = jsonBinding{}
View Source
var Protobuf = &protobufBinding{}
View Source
var Xml = &xmlBinding{}
Functions ¶
func ContentTypeFormat ¶ added in v1.2.0
func SetMimeType ¶ added in v1.2.0
Types ¶
type Binder ¶
type Binder interface { Id() uint8 // 1 Name() string //JSON String() string //application/json Encode(io.Writer, interface{}) error //同Marshal Decode(io.Reader, interface{}) error //同Unmarshal Marshal(interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error }
func GetContentType ¶ added in v1.2.0
func GetContentType(meta map[string]string, mod ContentTypeMod) (r Binder)
type ContentTypeMod ¶ added in v1.2.0
type ContentTypeMod int8
const ( ContentTypeModReq ContentTypeMod = iota ContentTypeModRes )
Click to show internal directories.
Click to hide internal directories.