Documentation
¶
Overview ¶
Package session provides the base secure http client and request management for akamai apis
Index ¶
Constants ¶
const (
// Version is the client version
Version = "9.0.0"
)
Variables ¶
var ( // ErrInvalidArgument is returned when invalid number of arguments were supplied to a function ErrInvalidArgument = errors.New("invalid arguments provided") // ErrMarshaling represents marshaling error ErrMarshaling = errors.New("marshaling input") // ErrUnmarshaling represents unmarshaling error ErrUnmarshaling = errors.New("unmarshaling output") )
Functions ¶
func CloseResponseBody ¶ added in v9.1.0
CloseResponseBody closes response body
func ContextWithOptions ¶
func ContextWithOptions(ctx context.Context, opts ...ContextOption) context.Context
ContextWithOptions adds request-specific options to the context This log debugs the request using only the provided log
func GetRetryableLogger ¶ added in v9.1.0
GetRetryableLogger returns wrapper retryablehttp.LeveledLogger for log.Interface
Types ¶
type ContextOption ¶
type ContextOption func(*contextOptions)
ContextOption are options on the context
func WithContextHeaders ¶
func WithContextHeaders(h http.Header) ContextOption
WithContextHeaders sets the context headers
func WithContextLog ¶
func WithContextLog(l log.Interface) ContextOption
WithContextLog provides a context specific logger
type Option ¶
type Option func(*session)
Option defines a client option
func WithClient ¶
WithClient creates a client using the specified http.Client
func WithHTTPTracing ¶
WithHTTPTracing sets the request and response dump for debugging
func WithRequestLimit ¶
WithRequestLimit sets the maximum number of API calls that the provider will make per second.
func WithRetries ¶ added in v9.1.0
func WithRetries(conf RetryConfig) Option
WithRetries configures the HTTP client to automatically retry failed GET requests
func WithSigner ¶
WithSigner sets the request signer for the session
func WithUserAgent ¶
WithUserAgent sets the user agent string for the client
type RetryConfig ¶ added in v9.1.0
type RetryConfig struct { RetryMax int RetryWaitMin time.Duration RetryWaitMax time.Duration ExcludedEndpoints []string }
RetryConfig struct contains http retry configuration.
ExcludedEndpoints field is a list of shell patterns. The pattern syntax is:
pattern: { term } term: '*' matches any sequence of non-/ characters '?' matches any single non-/ character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
func NewRetryConfig ¶ added in v9.1.0
func NewRetryConfig() RetryConfig
NewRetryConfig creates a new retry config with default settings.
type Session ¶
type Session interface { // Exec will sign and execute a request returning the response // The response body will be unmarshaled in to out // Optionally the in value will be marshaled into the body Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) // Sign will only sign a request, this is useful for circumstances // when the caller wishes to manage the http client Sign(r *http.Request) error // Log returns the logging interface for the session // If provided all debugging will output to this log interface Log(ctx context.Context) log.Interface // Client return the session http client Client() *http.Client }
Session is the interface that is used by the pa This allows the client itself to be more extensible and readily testable, ets.