Documentation ¶
Index ¶
- Constants
- func Default(httpReq *http.Request) (httpCode int, bodyBytes []byte, err error)
- func Do(httpReq *http.Request, opts ...Option) (httpCode int, bodyBytes []byte, err error)
- func DoWithClient(httpClient *http.Client, httpReq *http.Request) (httpCode int, bodyBytes []byte, err error)
- func ErrRequestFailure(code int) error
- func IsSuccessCode(code int) bool
- func NewGetRequest(httpURL string, body io.Reader) (httpReq *http.Request, err error)
- func NewHTTPClient(opts ...Option) *http.Client
- func NewPostRequest(httpURL string, body io.Reader) (httpReq *http.Request, err error)
- func NewRequest(httpMethod, httpURL string, body io.Reader) (httpReq *http.Request, err error)
- type Option
Constants ¶
View Source
const ( // DefaultTimeout timeout DefaultTimeout = time.Minute // ContentType header ContentType = "Content-Type" ContentTypeJSON = "application/json" ContentTypeJSONUtf8 = "application/json; charset=utf-8" ContentTypePB = "application/x-protobuf" // UserAgent Accept header UserAgent = "User-Agent" )
Variables ¶
This section is empty.
Functions ¶
func DoWithClient ¶
func DoWithClient(httpClient *http.Client, httpReq *http.Request) (httpCode int, bodyBytes []byte, err error)
DoWithClient 请求一次后关闭连接
func NewGetRequest ¶
NewGetRequest Get请求
func NewPostRequest ¶
NewPostRequest Post请求
Types ¶
Click to show internal directories.
Click to hide internal directories.