Documentation ¶
Index ¶
- Constants
- Variables
- func Do(ctx context.Context, method, url string, data interface{}, opentrace bool) (*http.Response, error)
- func DoRequest(r *http.Request) (*http.Response, error)
- func DoRequestWithCustomClient(cli *http.Client, r *http.Request) (*http.Response, error)
- func DoWithCustomClient(ctx context.Context, cli *http.Client, method, url string, data interface{}, ...) (*http.Response, error)
- func Parse(resp *http.Response, val interface{}) error
- func ParseHeaders(resp *http.Response, val interface{}) error
- func ParseJsonBody(resp *http.Response, val interface{}) error
Constants ¶
View Source
const ( // ApplicationJson stands for application/json. ApplicationJson = "application/json" // ContentType is the header key for Content-Type. ContentType = "Content-Type" // JsonContentType is the content type for JSON. JsonContentType = "application/json; charset=utf-8" )
Variables ¶
View Source
var ErrGetWithBody = errors.New("HTTP GET should not have body")
ErrGetWithBody indicates that GET request with body.
Functions ¶
func Do ¶
func Do(ctx context.Context, method, url string, data interface{}, opentrace bool) (*http.Response, error)
Do sends an HTTP request with the given arguments and returns an HTTP response, data is automatically marshal into a *httpRequest.
func DoRequestWithCustomClient ¶
DoRequestWithCustomClient sends an HTTP request and returns an HTTP response.
func DoWithCustomClient ¶
func DoWithCustomClient(ctx context.Context, cli *http.Client, method, url string, data interface{}, opentrace bool) (*http.Response, error)
DoWithCustomClient sends an HTTP request with the given arguments and returns an HTTP response, data is automatically marshal into a *httpRequest.
func ParseHeaders ¶
ParseHeaders parses the rsponse headers.
func ParseJsonBody ¶
ParseJsonBody parses the rsponse body, which should be in json content type.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.