Documentation ¶
Overview ¶
Package serialization 序列化相关的功能实现
Index ¶
- func New(c int) serializer.Serializer
- type FS
- type Item
- type Mimetypes
- type Serialization
- func (s *Serialization) Add(m serializer.MarshalFunc, u serializer.UnmarshalFunc, name ...string) error
- func (s *Serialization) Delete(name string)
- func (s *Serialization) Exists(name string) bool
- func (s *Serialization) Items() []string
- func (s *Serialization) Len() int
- func (s *Serialization) Search(name string) (string, serializer.MarshalFunc, serializer.UnmarshalFunc)
- func (s *Serialization) SearchFunc(match func(string) bool) (string, serializer.MarshalFunc, serializer.UnmarshalFunc)
- func (s *Serialization) Set(name string, m serializer.MarshalFunc, u serializer.UnmarshalFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(c int) serializer.Serializer
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
func (*FS) SearchByExt ¶
func (f *FS) SearchByExt(filename string) (serializer.MarshalFunc, serializer.UnmarshalFunc)
func (*FS) Serializer ¶
func (f *FS) Serializer() serializer.Serializer
type Item ¶
type Item struct { Name string Marshal serializer.MarshalFunc Unmarshal serializer.UnmarshalFunc }
type Mimetypes ¶
type Mimetypes struct {
serializer.Serializer
}
func NewMimetypes ¶
func (*Mimetypes) ContentType ¶
func (ms *Mimetypes) ContentType(h string) (serializer.UnmarshalFunc, encoding.Encoding, error)
ContentType 从 content-type 报头中获取解码和字符集函数
h 表示 content-type 报头的内容。如果字符集为 utf-8 或是未指定,返回的字符解码为 nil;
func (*Mimetypes) MarshalFunc ¶
func (ms *Mimetypes) MarshalFunc(h string) (string, serializer.MarshalFunc, bool)
MarshalFunc 从 h 解析出当前请求所需要的 mimetype 名称和对应的解码函数
*/* 或是空值 表示匹配任意内容,一般会选择第一个元素作匹配; xx/* 表示匹配以 xx/ 开头的任意元素,一般会选择 xx/* 开头的第一个元素; xx/ 表示完全匹配以 xx/ 的内容 如果传递的内容如下:
application/json;q=0.9,*/*;q=1
则因为 */* 的 q 值比较高,而返回 */* 匹配的内容
在不完全匹配的情况下,返回值的名称依然是具体名称。
text/*;q=0.9
返回的名称可能是:
text/plain
type Serialization ¶
type Serialization struct {
// contains filtered or unexported fields
}
func (*Serialization) Add ¶
func (s *Serialization) Add(m serializer.MarshalFunc, u serializer.UnmarshalFunc, name ...string) error
func (*Serialization) Delete ¶
func (s *Serialization) Delete(name string)
func (*Serialization) Exists ¶ added in v0.59.1
func (s *Serialization) Exists(name string) bool
func (*Serialization) Items ¶ added in v0.59.1
func (s *Serialization) Items() []string
func (*Serialization) Len ¶
func (s *Serialization) Len() int
func (*Serialization) Search ¶
func (s *Serialization) Search(name string) (string, serializer.MarshalFunc, serializer.UnmarshalFunc)
func (*Serialization) SearchFunc ¶
func (s *Serialization) SearchFunc(match func(string) bool) (string, serializer.MarshalFunc, serializer.UnmarshalFunc)
func (*Serialization) Set ¶
func (s *Serialization) Set(name string, m serializer.MarshalFunc, u serializer.UnmarshalFunc)
Click to show internal directories.
Click to hide internal directories.