edgegrid

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

README

Akamai Edgegrid

A golang package which facilitates authenticating and signing requests made to Akamai OPEN APIs.

Documentation

Overview

Package edgegrid allows you to sign http.Request's using the Akamai OPEN Edgegrid Signing Scheme

Index

Constants

View Source
const (
	ErrUUIDGenerateFailed   = 500
	ErrHomeDirNotFound      = 501
	ErrConfigFile           = 502
	ErrConfigFileSection    = 503
	ErrConfigMissingOptions = 504
	ErrMissingEnvVariables  = 505
)

Error constants

Variables

This section is empty.

Functions

func AddRequestHeader

func AddRequestHeader(config Config, req *http.Request) *http.Request

AddRequestHeader sets the Authorization header to use Akamai Open API

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"`
	HeaderToSign []string `ini:"headers_to_sign"`
	MaxBody      int      `ini:"max_body"`
	Debug        bool     `ini:"debug"`
}

Config struct provides all the necessary fields to create authorization header, debug is optional

func Init

func Init(filepath string, section string) (Config, error)

Init initializes by first attempting to use ENV vars, with .edgerc as a fallback

See: InitEnv() See: InitEdgeRc()

func InitEdgeRc

func InitEdgeRc(filepath string, section string) (Config, error)

InitEdgeRc initializes using a configuration file in standard INI format

By default, it uses the .edgerc found in the users home directory, and the "default" section.

func InitEnv

func InitEnv(section string) (Config, error)

InitEnv initializes 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_.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL