Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RawTypesMap = map[RawType]string{ RawTypeText: "text/plain; charset=utf-8", RawTypeHtml: "text/html; charset=utf-8", RawTypeJson: "application/json; charset=utf-8", RawTypeXml: "application/xml; charset=utf-8", RawTypeUrlEncodedForm: "application/x-www-form-urlencoded; charset=utf-8", }
RawTypesMap HTTP content-type map
Functions ¶
func SetGlobalHttpClient ¶
SetGlobalHttpClient set default http client
Types ¶
type PackedReq ¶
type PackedReq struct { // if nil, use global.defaultHttpClient Client *http.Client Ctx context.Context URL string Method string Header map[string]string // if nil, use PublisherNoBody ReqBodyPublisher ReqBodyPublisher // if nil, use RespBodyNoHandle RespBodyHandler RespBodyHandler }
PackedReq is a struct used to define the HTTP request
type PublisherNoBody ¶
type PublisherNoBody struct{}
PublisherNoBody is the implement of ReqBodyPublisher
-> No request body
func (PublisherNoBody) Subscribe ¶
func (e PublisherNoBody) Subscribe() ReqBody
Subscribe the empty request body
type PublisherRawBytesBody ¶
PublisherRawBytesBody is the implement of ReqBodyPublisher
-> Byte array request body
func (PublisherRawBytesBody) Subscribe ¶
func (raw PublisherRawBytesBody) Subscribe() ReqBody
Subscribe the byte array request body
type PublisherRawStringBody ¶
PublisherRawStringBody is the implement of ReqBodyPublisher
-> String request body
func (PublisherRawStringBody) Subscribe ¶
func (raw PublisherRawStringBody) Subscribe() ReqBody
Subscribe the string request body
type RawType ¶
type RawType int
RawType HTTP content-type enum
const ( // RawTypeText "text/plain; charset=utf-8" RawTypeText RawType = iota // RawTypeHtml "text/html; charset=utf-8" RawTypeHtml // RawTypeJson "application/json; charset=utf-8" RawTypeJson // RawTypeXml "application/xml; charset=utf-8" RawTypeXml // RawTypeUrlEncodedForm "application/x-www-form-urlencoded; charset=utf-8" RawTypeUrlEncodedForm )
type ReqBody ¶
type ReqBody struct { // Request body Content io.Reader // Content-Length Length int64 // Content-type Type string }
ReqBody need by stdlib HTTP client
type ReqBodyPublisher ¶
type ReqBodyPublisher interface {
Subscribe() ReqBody
}
ReqBodyPublisher processing request body
type RespBodyAsByteArray ¶
type RespBodyAsByteArray struct{}
RespBodyAsByteArray is the implement of RespBodyHandler
-> Read body as byte array
func (RespBodyAsByteArray) Apply ¶
func (r RespBodyAsByteArray) Apply(body io.ReadCloser) (interface{}, error)
Apply the handle
type RespBodyHandler ¶
type RespBodyHandler interface { // Apply the handle of response body Apply(body io.ReadCloser) (interface{}, error) }
RespBodyHandler processing response body
type RespBodyNoHandle ¶
type RespBodyNoHandle struct{}
RespBodyNoHandle is the implement of RespBodyHandler
-> No read body
func (RespBodyNoHandle) Apply ¶
func (r RespBodyNoHandle) Apply(_ io.ReadCloser) (interface{}, error)
Apply the handle