edgegrid

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 18 Imported by: 203

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

View Source
var LogFile *os.File

Functions

func AddRequestHeader

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

AddRequestHeader sets the Authorization header to use Akamai Open API

func LogMultiline added in v0.9.0

func LogMultiline(f func(args ...interface{}), args ...string)

func LogMultilinef added in v0.9.0

func LogMultilinef(f func(formatter string, args ...interface{}), formatter string, args ...interface{})

func LogMultilineln added in v0.9.0

func LogMultilineln(f func(args ...interface{}), args ...string)

func SetupLogging added in v0.9.0

func SetupLogging(log *logrus.Logger)

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"`
	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