Documentation ¶
Index ¶
- Constants
- func IsClientError(r *http.Response) bool
- func IsError(r *http.Response) bool
- func IsInformational(r *http.Response) bool
- func IsRedirection(r *http.Response) bool
- func IsServerError(r *http.Response) bool
- func IsSuccess(r *http.Response) bool
- func NewHTTPClient() *http.Client
- type APIError
- type ResponseResult
- type ServiceClient
- func (client *ServiceClient) DoRequest(ctx context.Context, method, path string, body interface{}) (*ResponseResult, error)
- func (client *ServiceClient) DoRequestWithCustomHeaders(ctx context.Context, method, path string, headers http.Header, ...) (*ResponseResult, error)
- func (client *ServiceClient) SetLogger(log logger.GenericLogger)
- type Warning
Constants ¶
const ( // AppVersion is a version of the application. AppVersion = "0.0.1" // AppName is a global application name. AppName = "go-akamai" // DefaultUserAgent contains basic user agent that will be used in queries. DefaultUserAgent = AppName + "/" + AppVersion )
Variables ¶
This section is empty.
Functions ¶
func IsClientError ¶
IsClientError determines if a response was a client error (4XX status)
func IsInformational ¶
IsInformational determines if a response was informational (1XX status)
func IsRedirection ¶
IsRedirection determines if a response was a redirect (3XX status)
func IsServerError ¶
IsServerError determines if a response was a server error (5XX status)
func NewHTTPClient ¶
NewHTTPClient returns a reference to an initialized configured HTTP client.
Types ¶
type APIError ¶
type APIError struct { Type string `json:"type"` Title string `json:"title"` Status int `json:"status"` Detail string `json:"detail"` Instance string `json:"instance"` Method string `json:"method"` ServerIP string `json:"serverIp"` ClientIP string `json:"clientIp"` RequestID string `json:"requestId"` RequestTime string `json:"requestTime"` Warnings []Warning `json:"warnings"` Response *http.Response `json:"-"` RawBody string `json:"-"` // contains filtered or unexported fields }
APIError exposes an Akamai OPEN Edge Grid Error.
func NewAPIError ¶
NewAPIError creates a new API error based on a Response, or http.Response-like.
func NewAPIErrorFromBody ¶
NewAPIErrorFromBody creates a new API error, allowing you to pass in a body
This function is intended to be used after the body has already been read for other purposes.
type ResponseResult ¶
type ResponseResult struct { *http.Response // Err contains error that can be provided to a caller. Err *APIError }
ResponseResult represents a result of a HTTP request. It embeds standard http.Response and adds a custom error description.
func (*ResponseResult) ExtractResult ¶
func (result *ResponseResult) ExtractResult(to interface{}) error
ExtractResult allows to provide an object into which ResponseResult body will be extracted.
type ServiceClient ¶
type ServiceClient struct { // HTTPClient represents an initialized HTTP client that will be used to do requests. HTTPClient *http.Client // Endpoint represents an endpoint that will be used in all requests. Endpoint string // UserAgent contains user agent that will be used in all requests. UserAgent string // Config represents Akamai Edge Grid config. Config *edgegrid.Config // contains filtered or unexported fields }
ServiceClient stores details that are needed to work with different Akamai APIs.
func (*ServiceClient) DoRequest ¶
func (client *ServiceClient) DoRequest(ctx context.Context, method, path string, body interface{}) (*ResponseResult, error)
DoRequest creates an HTTP request and sends it to Akamai APIs. A relative URL can be provided in path, which will be resolved to the Host specified in Config. If body is specified, it will be sent as the request body.
func (*ServiceClient) DoRequestWithCustomHeaders ¶
func (client *ServiceClient) DoRequestWithCustomHeaders(ctx context.Context, method, path string, headers http.Header, body interface{}) (*ResponseResult, error)
DoRequestWithCustomHeaders creates an HTTP request with re-written headers and sends it to Akamai APIs. A relative URL can be provided in path, which will be resolved to the Host specified in Config. If body is specified, it will be sent as the JSON request body.
func (*ServiceClient) SetLogger ¶
func (client *ServiceClient) SetLogger(log logger.GenericLogger)
SetLogger sets logger to the given.
Directories ¶
Path | Synopsis |
---|---|
Package edgegrid allows you to sign up your request to calling Akamai APIs.
|
Package edgegrid allows you to sign up your request to calling Akamai APIs. |
internal
|
|