Documentation ¶
Overview ¶
Package client is a simple library for http.Client to sign Akamai OPEN Edgegrid API requests
Index ¶
- Variables
- func BodyJSON(r *http.Response, data interface{}) error
- func Do(config edgegrid.Config, req *http.Request) (*http.Response, error)
- 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 NewJSONRequest(config edgegrid.Config, method, path string, body interface{}) (*http.Request, error)
- func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, ...) (*http.Request, error)
- func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error)
- type APIError
- type APIErrorDetail
- type JSONBody
- type Resource
Constants ¶
This section is empty.
Variables ¶
var ( // UserAgent is the User-Agent value sent for all requests UserAgent = "Akamai-Open-Edgegrid-golang/" + libraryVersion + " golang/" + strings.TrimPrefix(runtime.Version(), "go") // Client is the *http.Client to use Client = http.DefaultClient )
Functions ¶
func Do ¶
Do performs a given HTTP Request, signed with the Akamai OPEN Edgegrid Authorization header. An edgegrid.Response or an error is returned.
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 NewJSONRequest ¶
func NewJSONRequest(config edgegrid.Config, method, path string, body interface{}) (*http.Request, error)
NewJSONRequest creates an HTTP request that can be sent to the Akamai APIs with a JSON body The JSON body is encoded and the Content-Type/Accept headers are set automatically.
func NewMultiPartFormDataRequest ¶ added in v0.7.0
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error)
NewMultiPartFormDataRequest creates an HTTP request that uploads a file to the Akamai API
func NewRequest ¶
NewRequest creates an HTTP request that can be sent 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.
Types ¶
type APIError ¶
type APIError struct { Type string `json:"type"` Title string `json:"title"` Status int `json:"status"` Detail string `json:"detail"` Errors []APIErrorDetail `json:"errors"` Problems []APIErrorDetail `json:"problems"` Instance string `json:"instance"` Method string `json:"method"` ServerIP string `json:"serverIp"` ClientIP string `json:"clientIp"` RequestID string `json:"requestId"` RequestTime string `json:"requestTime"` Response *http.Response `json:"-"` RawBody string `json:"-"` // contains filtered or unexported fields }
APIError exposes an Akamai OPEN Edgegrid 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 APIErrorDetail ¶ added in v0.7.0
type JSONBody ¶
type JSONBody map[string]interface{}
JSONBody is a generic struct for temporary JSON unmarshalling.
type Resource ¶
type Resource struct {
Complete chan bool `json:"-"`
}
Resource is the "base" type for all API resources
func (*Resource) Init ¶
func (resource *Resource) Init()
Init initializes the Complete channel, if it is necessary need to create a resource specific Init(), make sure to initialize the channel.
func (*Resource) PostUnmarshalJSON ¶
PostUnmarshalJSON is a default implementation of the PostUnmarshalJSON hook that simply calls Init() and sends true to the Complete channel. This is overridden in many resources, in particular those that represent collections, and have to initialize sub-resources also.