Documentation
¶
Index ¶
- Constants
- func GetTestingServer() *httptest.Server
- func MergeHeaders(headers, headersToMerge map[string]string)
- func ReadBytes(input io.Reader) ([]byte, error)
- func SetHeaders(headers map[string]string, name, value string)
- type ApiResponse
- type Authenticator
- type CallBuilder
- type CallBuilderFactory
- type FileWrapper
- type FormParam
- type HttpCallExecutor
- type HttpClient
- type HttpClientInterface
- type HttpConfiguration
- type HttpConfigurationOptions
- type HttpContext
- type HttpInterceptor
- type RequestRetryOption
- type RetryConfiguration
- func (r *RetryConfiguration) BackoffFactor() int64
- func (rc *RetryConfiguration) GetRetryWaitTime(maxWaitTime time.Duration, retryCount int64, response *http.Response, ...) time.Duration
- func (r *RetryConfiguration) HttpMethodsToRetry() []string
- func (r *RetryConfiguration) HttpStatusCodesToRetry() []int64
- func (r *RetryConfiguration) MaxRetryAttempts() int64
- func (r *RetryConfiguration) MaximumRetryWaitTime() time.Duration
- func (r *RetryConfiguration) RetryInterval() time.Duration
- func (r *RetryConfiguration) RetryOnTimeout() bool
- func (rc *RetryConfiguration) ShouldRetry(retryRequestOption RequestRetryOption, httpMethod string) bool
- type RetryConfigurationOptions
- func WithBackoffFactor(backoffFactor int64) RetryConfigurationOptions
- func WithHttpMethodsToRetry(httpMethodsToRetry []string) RetryConfigurationOptions
- func WithHttpStatusCodesToRetry(httpStatusCodesToRetry []int64) RetryConfigurationOptions
- func WithMaxRetryAttempts(maxRetryAttempts int64) RetryConfigurationOptions
- func WithMaximumRetryWaitTime(maximumRetryWaitTime time.Duration) RetryConfigurationOptions
- func WithRetryInterval(retryInterval time.Duration) RetryConfigurationOptions
- func WithRetryOnTimeout(retryOnTimeout bool) RetryConfigurationOptions
Constants ¶
View Source
const ACCEPT_HEADER = "accept"
View Source
const AUTHORIZATION_HEADER = "authorization"
View Source
const CONTENT_LENGTH_HEADER = "content-length"
View Source
const CONTENT_TYPE_HEADER = "content-type"
View Source
const FORM_URLENCODED_CONTENT_TYPE = "application/x-www-form-urlencoded"
View Source
const JSON_CONTENT_TYPE = "application/json"
View Source
const MULTIPART_CONTENT_TYPE = "multipart/form-data"
View Source
const TEXT_CONTENT_TYPE = "text/plain; charset=utf-8"
View Source
const XML_CONTENT_TYPE = "application/xml"
Variables ¶
This section is empty.
Functions ¶
func GetTestingServer ¶
func MergeHeaders ¶
func SetHeaders ¶
Types ¶
type ApiResponse ¶
func NewApiResponse ¶
func NewApiResponse[T any](data T, response *http.Response) ApiResponse[T]
type Authenticator ¶
type Authenticator func(bool) HttpInterceptor
type CallBuilder ¶
type CallBuilder interface { AppendPath(path string) AppendTemplateParam(param string) AppendTemplateParams(params interface{}) BaseUrl(arg string) Method(httpMethodName string) Accept(acceptHeaderValue string) ContentType(contentTypeHeaderValue string) Header(name string, value interface{}) CombineHeaders(headersToMerge map[string]string) QueryParam(name string, value interface{}) QueryParams(parameters map[string]interface{}) FormParam(name string, value interface{}) FormData(fields []FormParam) Text(body string) FileStream(file FileWrapper) Json(data interface{}) InterceptRequest(interceptor func(httpRequest *http.Request) *http.Request) Call() (*HttpContext, error) CallAsJson() (*json.Decoder, *http.Response, error) CallAsText() (string, *http.Response, error) CallAsStream() ([]byte, *http.Response, error) Authenticate(requiresAuth bool) RequestRetryOption(option RequestRetryOption) // contains filtered or unexported methods }
type CallBuilderFactory ¶
type CallBuilderFactory func(ctx context.Context, httpMethod, path string) CallBuilder
func CreateCallBuilderFactory ¶
func CreateCallBuilderFactory( baseUrlProvider baseUrlProvider, auth Authenticator, httpClient HttpClient, retryConfig RetryConfiguration, ) CallBuilderFactory
type FileWrapper ¶
func GetFile ¶
func GetFile(fileUrl string) (FileWrapper, error)
type HttpCallExecutor ¶
type HttpCallExecutor func(request *http.Request) HttpContext
func CallHttpInterceptors ¶
func CallHttpInterceptors( interceptors []HttpInterceptor, client HttpCallExecutor, ) HttpCallExecutor
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(httpConfig HttpConfiguration) HttpClient
type HttpClientInterface ¶
type HttpConfiguration ¶
type HttpConfiguration struct {
// contains filtered or unexported fields
}
func NewHttpConfiguration ¶
func NewHttpConfiguration(options ...HttpConfigurationOptions) HttpConfiguration
func (*HttpConfiguration) RetryConfiguration ¶
func (h *HttpConfiguration) RetryConfiguration() RetryConfiguration
func (*HttpConfiguration) Timeout ¶
func (h *HttpConfiguration) Timeout() float64
func (*HttpConfiguration) Transport ¶
func (h *HttpConfiguration) Transport() http.RoundTripper
type HttpConfigurationOptions ¶
type HttpConfigurationOptions func(*HttpConfiguration)
func WithRetryConfiguration ¶
func WithRetryConfiguration(retryConfig RetryConfiguration) HttpConfigurationOptions
func WithTimeout ¶
func WithTimeout(timeout float64) HttpConfigurationOptions
func WithTransport ¶
func WithTransport(transport http.RoundTripper) HttpConfigurationOptions
type HttpContext ¶
func PassThroughInterceptor ¶
func PassThroughInterceptor( req *http.Request, next HttpCallExecutor, ) HttpContext
type HttpInterceptor ¶
type HttpInterceptor func(request *http.Request, next HttpCallExecutor) HttpContext
type RequestRetryOption ¶
type RequestRetryOption int
const ( Default RequestRetryOption = iota Enable Disable )
func (RequestRetryOption) String ¶
func (r RequestRetryOption) String() string
type RetryConfiguration ¶
type RetryConfiguration struct {
// contains filtered or unexported fields
}
func NewRetryConfiguration ¶
func NewRetryConfiguration(options ...RetryConfigurationOptions) RetryConfiguration
func (*RetryConfiguration) BackoffFactor ¶
func (r *RetryConfiguration) BackoffFactor() int64
func (*RetryConfiguration) GetRetryWaitTime ¶
func (*RetryConfiguration) HttpMethodsToRetry ¶
func (r *RetryConfiguration) HttpMethodsToRetry() []string
func (*RetryConfiguration) HttpStatusCodesToRetry ¶
func (r *RetryConfiguration) HttpStatusCodesToRetry() []int64
func (*RetryConfiguration) MaxRetryAttempts ¶
func (r *RetryConfiguration) MaxRetryAttempts() int64
func (*RetryConfiguration) MaximumRetryWaitTime ¶
func (r *RetryConfiguration) MaximumRetryWaitTime() time.Duration
func (*RetryConfiguration) RetryInterval ¶
func (r *RetryConfiguration) RetryInterval() time.Duration
func (*RetryConfiguration) RetryOnTimeout ¶
func (r *RetryConfiguration) RetryOnTimeout() bool
func (*RetryConfiguration) ShouldRetry ¶
func (rc *RetryConfiguration) ShouldRetry(retryRequestOption RequestRetryOption, httpMethod string) bool
type RetryConfigurationOptions ¶
type RetryConfigurationOptions func(*RetryConfiguration)
func WithBackoffFactor ¶
func WithBackoffFactor(backoffFactor int64) RetryConfigurationOptions
func WithHttpMethodsToRetry ¶
func WithHttpMethodsToRetry(httpMethodsToRetry []string) RetryConfigurationOptions
func WithHttpStatusCodesToRetry ¶
func WithHttpStatusCodesToRetry(httpStatusCodesToRetry []int64) RetryConfigurationOptions
func WithMaxRetryAttempts ¶
func WithMaxRetryAttempts(maxRetryAttempts int64) RetryConfigurationOptions
func WithMaximumRetryWaitTime ¶
func WithMaximumRetryWaitTime(maximumRetryWaitTime time.Duration) RetryConfigurationOptions
func WithRetryInterval ¶
func WithRetryInterval(retryInterval time.Duration) RetryConfigurationOptions
func WithRetryOnTimeout ¶
func WithRetryOnTimeout(retryOnTimeout bool) RetryConfigurationOptions
Click to show internal directories.
Click to hide internal directories.