Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 946 Bytes

README.md

File metadata and controls

51 lines (35 loc) · 946 Bytes

fastly-tokens

Generate tokens for securing content distributed with the Fastly CDN, in go!

Usage

Install the fastly-tokens library: go get github.com/zencoder/fastly-tokens/ft

package main

import (
  "encoding/base64"
  "fmt"
  "log"
  "time"

  "github.com/zencoder/fastly-tokens/ft"
)

func main() {
	// Generate token that is valid for 60 seconds using the default secret
	token := ft.GenerateToken("RmFzdGx5IFRva2VuIFRlc3Q=", 60*time.Second, base64.StdEncoding)
	fmt.Printf("Token: %s\n", token)
}

Benchmarks

BenchmarkGenerateToken-8   	 1000000	      1771 ns/op	     848 B/op	      12 allocs/op
PASS
ok  	github.com/zencoder/fastly-tokens/ft	2.101s

Development

Dependencies

Tested on go 1.13

Build and run unit tests

make

CI

This library builds on Circle CI, here.

License

Apache License Version 2.0