Documentation
¶
Overview ¶
Package mimetypes 管理与 Mimetype 相关的数据
Index ¶
- type Mimetype
- type Mimetypes
- func (ms *Mimetypes[M, U]) Accept(h string) *Mimetype[M, U]
- func (ms *Mimetypes[M, U]) AcceptHeader() string
- func (ms *Mimetypes[M, U]) Add(name string, m M, u U, problem string)
- func (ms *Mimetypes[M, U]) ContentType(h string) (U, encoding.Encoding, error)
- func (ms *Mimetypes[M, U]) Search(name string) *Mimetype[M, U]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mimetypes ¶
Mimetypes 提供对 mimetype 的管理
M 表示解码方法的类型; U 表示编码方法的类型;
func (*Mimetypes[M, U]) Accept ¶ added in v0.70.0
Accept 从请求端提交的 accept 报头解析出所需要的解码函数
*/* 或是空值 表示匹配任意内容,一般会选择第一个元素作匹配; xx/* 表示匹配以 xx/ 开头的任意元素,一般会选择 xx/* 开头的第一个元素; xx/ 表示完全匹配以 xx/ 的内容 如果传递的内容如下:
application/json;q=0.9,*/*;q=1
则因为 */* 的 q 值比较高,而返回 */* 匹配的内容
func (*Mimetypes[M, U]) AcceptHeader ¶ added in v0.85.0
func (ms *Mimetypes[M, U]) AcceptHeader() string
AcceptHeader 根据当前的内容生成 Accept 报头
func (*Mimetypes[M, U]) Add ¶
Add 添加新的编码方法
name 为编码名称; problem 为该编码在返回 [web.Problem] 对象时的 mimetype 报头值,如果为空,则会与 name 值相同;
func (*Mimetypes[M, U]) ContentType ¶
ContentType 从请求端提交的 content-type 报头中获取解码和字符集函数
h 表示 content-type 报头的内容。如果字符集为 utf-8 或是未指定,返回的字符解码为 nil;
Click to show internal directories.
Click to hide internal directories.