You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new fluent http adapter that wraps net.http and adds logging and retry with backoff
import (
"github.com/flanksource/commons/logger""net/http"
)
typeHttpClientstruct {
InsecureSkipVerifyboolDialContextfunc(ctx context.Context, network, addrstring) (net.Conn, error)
// Headers are automatically added to all requestsHeadersmap[string]string// BaseURL is added as a prefix to all URL'sBaseURLstring// LOGGING// Specify if request/response bodies should be loggedTraceBodyboolTraceResponseboolTracebool// GET's are on TRACE, PUT/PATCH/POST are on Debug, and DELETE are on InfoLoggerLogger// RETRY HANDLING// Cancel the request after this timeoutTimeout time.Duration// Number of retries to attemptRetriesint// Time to wait between retriesRetryWait time.Duration// Amount to increase RetryWait with each failure, 2.0 is a good option for exponential backoffFactorfloat32
}
typeHttpResponsestruct {
*http.Response
}
func (resp*HttpResponse) IsOK() bool {}
func (resp*HttpResponse) AsError() error {}
func (resp*HttpResponse) AsString() (string,error) {}
func (resp*HttpResponse) AsReader() (io.Reader, error) {}
func (resp*HttpResponse) AsBytes() ([]byte,error) {}
func (client*HttpClient) Get(urlstring) HttpResponse {}
func (client*HttpClient) Post(urlstring, bodyinterface{}) HttpResponse {}
func (client*HttpClient) Delete(urlstring) HttpResponse {}
func (client*HttpClient) Patch(urlstring, bodyinterface{}) HttpResponse {}
func (client*HttpClient) Put(urlstring, bodyinterface{}) HttpResponse {}
The text was updated successfully, but these errors were encountered:
Create a new fluent http adapter that wraps net.http and adds logging and retry with backoff
The text was updated successfully, but these errors were encountered: