Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EncodeRequestBody = request.Hook{Name: "core.EncodeRequestBody", Fn: func(r *request.Request) { if r.Params == nil { return } buf := new(bytes.Buffer) if err := jsoniter.NewEncoder(buf).Encode(r.Params); err != nil { r.Error = err return } r.Request.Body = io.NopCloser(buf) }}
EncodeRequestBody converts the value in r.Params into an io reader and adds it to the http.Request instance
var LogHTTPRequest = request.Hook{Name: "core.LogHTTPRequest", Fn: logRequest}
LogHTTPRequest is a hook to log the HTTP request sent to a service. If log level matches request.LogDebugWithHTTPBody, the request body will be included.
var ResolveEndpoint = request.Hook{Name: "core.ResolveEndpoint", Fn: func(r *request.Request) { r.Config.Endpoint = AddScheme(r.Config.Endpoint, r.Config.DisableSSL) }}
var SendHook = request.Hook{Name: "core.Send", Fn: func(r *request.Request) { sender := sendFollowRedirects if r.Config.DisableFollowRedirects { sender = sendWithoutFollowRedirects } if r.Request.Body == request.NoBody { reqOrig, reqCopy := r.Request, *r.Request reqCopy.Body = nil r.Request = &reqCopy defer func() { r.Request = reqOrig }() } var err error r.Response, err = sender(r) if err != nil { handleSendError(r, err) } }}
Functions ¶
func AddScheme ¶
AddScheme adds the HTTP or HTTPS schemes to an endpoint URL if there is no scheme. If disableSSL is true, HTTP will set HTTP instead of the default HTTPS.
If disableSSL is set, it will only set the URL's scheme if the URL does not contain a scheme.
func DefaultHooks ¶
func SetBasicAuth ¶
SetBasicAuth modifies the http.Request headers and adds basic auth credentials
func SetHTTPClient ¶
SetHTTPClient sets the http.Client to be used for requests. Sets a default http.Client if none is provided with a timeout of 30 seconds.
func SetRequestID ¶
SetRequestID will set a default request id to the request if no id generator function is given