Documentation ¶
Overview ¶
Package edgegrid provides Akamai .edgerc configuration parsing and http.Request signing.
Index ¶
Constants ¶
const ( // DefaultConfigFile is the default configuration file path DefaultConfigFile = "~/.edgerc" // DefaultSection is the .edgerc ini default section DefaultSection = "default" // MaxBodySize is the max payload size for client requests MaxBodySize = 131072 )
Variables ¶
var ( // ErrRequiredOptionEnv is returned when a required ENV variable is not found ErrRequiredOptionEnv = errors.New("required option is missing from env") // ErrRequiredOptionEdgerc is returned when a required value is not found in edgerc file ErrRequiredOptionEdgerc = errors.New("required option is missing from edgerc") // ErrLoadingFile indicates problem with loading configuration file ErrLoadingFile = errors.New("loading config file") // ErrSectionDoesNotExist is returned when a section with provided name does not exist in edgerc ErrSectionDoesNotExist = errors.New("provided config section does not exist") // ErrHostContainsSlashAtTheEnd is returned when host has unnecessary '/' at the end ErrHostContainsSlashAtTheEnd = errors.New("host must not contain '/' at the end") )
Functions ¶
Types ¶
type Config ¶
type Config struct { Host string `ini:"host"` ClientToken string `ini:"client_token"` ClientSecret string `ini:"client_secret"` AccessToken string `ini:"access_token"` AccountKey string `ini:"account_key"` HeaderToSign []string `ini:"headers_to_sign"` MaxBody int `ini:"max_body"` RequestLimit int `ini:"request_limit"` Debug bool `ini:"debug"` // contains filtered or unexported fields }
Config struct provides all the necessary fields to create authorization header, debug is optional
func (Config) CheckRequestLimit ¶
CheckRequestLimit waits if necessary to ensure that OpenAPI's request limit is not exceeded
func (*Config) FromEnv ¶
FromEnv creates a new config using the Environment (ENV)
By default, it uses AKAMAI_HOST, AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, AKAMAI_ACCESS_TOKEN and AKAMAI_MAX_BODY variables.
You can define multiple configurations by prefixing with the section name specified, e.g. passing "ccu" will cause it to look for AKAMAI_CCU_HOST, etc.
If AKAMAI_{SECTION} does not exist, it will fall back to just AKAMAI_.
func (Config) SignRequest ¶
SignRequest adds a signed authorization header to the http request