bestcookie

package module
v0.0.0-...-b1e455e Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 13 Imported by: 0

README

bestcookie

Implements the BestCookie algorithm in Go

Documentation

Overview

Package bestcookie implements the bestcookie algorithm and provides this to Golang's HTTP server.

__Setup__ > go get github.com/snadrus/bestcookie

__Run as Part of Builds__ go run bestcookie.go <mykeys.go >mykeys.go Only the global private "bestCookieKeys" gets replaced:

package mypkg
var bestCookieKeys = []bestcookie.Keys{}

Use in code:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RotateKeys

func RotateKeys(keys *[]Key)

RotateKeys result should be shared with all servers. Call this at build time: go run bestcookie.go <mykeys.go >mykeys.go Only the global private "bestCookieKeys" gets replaced:

package mypkg
var bestCookieKeys = []bestcookie.Keys{}

Types

type BestCookie

type BestCookie struct {
	// contains filtered or unexported fields
}

func New

func New(cookieName string, keys []Key, timeout time.Duration) *BestCookie

func (*BestCookie) Middleware

func (b *BestCookie) Middleware(next http.Handler) http.Handler

func (*BestCookie) UpdateCookieBytes

func (b *BestCookie) UpdateCookieBytes(w http.ResponseWriter, msg interface{}) error

UpdateCookie adds or updates a cookie

type Key

type Key struct {
	Month byte
	Year  uint16
	Key   string
}

Jump to

Keyboard shortcuts

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