Documentation
¶
Index ¶
Constants ¶
View Source
const ( MIMEJSON = "application/json" MIMEXML = "application/xml" MIMETEXTXML = "text/xml" MIMEHTML = "text/html" MIMETEXT = "text/plain" MIMEPOSTFORM = "application/x-www-form-urlencoded" MIMEMultipartPOSTFORM = "multipart/form-data" )
Content-Type MIME of the data formats.
View Source
const HeaderContentType = "Content-Type"
HeaderContentType content-type header key
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Body ¶
type Body interface { // Body 构造http请求body Body() (io.Reader, error) // ContentType 返回 body 体结构相应的 Header content-type 类型 ContentType() string }
Body 构造请求的body
type File ¶
type File struct { Field string // 表单字段 Filename string // 文件名称 ContentType string // 文件 content-type;若不指定,则根据 Content 判断 Content []byte // 文件内容 }
File 文件
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form 用于构建一个 x-www-form-urlencoded 消息格式的 body 体
func NewFormFromMap ¶
NewFormFromMap return new Form from map
func (*Form) ContentType ¶
ContentType 构建 x-www-form-urlencoded 消息类型对应的content-type头信息
type MultipartForm ¶
type MultipartForm struct {
// contains filtered or unexported fields
}
MultipartForm multipart/form-data
func NewMultipartForm ¶
func NewMultipartForm(uv url.Values, fs ...File) *MultipartForm
NewMultipartForm return new MultipartForm from url.Values
func NewMultipartFormFromMap ¶
func NewMultipartFormFromMap(m map[string]interface{}, fs ...File) *MultipartForm
NewMultipartFormFromMap return new MultipartForm from map
func (*MultipartForm) Body ¶
func (mf *MultipartForm) Body() (io.Reader, error)
Body 构建 multipart/form-data 格式的消息体
func (*MultipartForm) ContentType ¶
func (mf *MultipartForm) ContentType() string
ContentType 构建 multipart/form-data 格式的 header 头
func (*MultipartForm) CreateFormFile ¶
func (mf *MultipartForm) CreateFormFile(w *multipart.Writer, fieldName, filename string, contentType string, fileContent []byte) (int, error)
CreateFormFile Create form file
Click to show internal directories.
Click to hide internal directories.