common

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// HashKeySize is optimally 64 bytes
	HashKeySize = 64
	// BlockKeySize is optimally 32 bytes
	BlockKeySize = 32
)

Variables

This section is empty.

Functions

func Decode

func Decode(hash string) ([]byte, error)

Decode extracts a byte slice from a base64 encoded string.

func Generate

func Generate(keysize int) string

Generate creates a random key of keysize length, and returns it in base64 encoded text.

func JSONResponse

func JSONResponse(w http.ResponseWriter, o interface{})

JSONResponse writes the interface{} o as a JSON object response body.

func JSONStatusResponse

func JSONStatusResponse(code int, w http.ResponseWriter, o interface{})

JSONStatusResponse writes the interface{} o as a JSON object response body with the givent http status code.

func QueryParamKeys

func QueryParamKeys(v url.Values) []string

QueryParamKeys gets the keys from a url.Values collection.

func Redirect

func Redirect(w http.ResponseWriter, r *http.Request, targetURL string, additionalParams map[string]string)

Redirect initiates an http redirect response.

Types

type DebugMiddleware

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

DebugMiddleware provides request/response logging.

func NewDebugMiddleware

func NewDebugMiddleware(w io.Writer, verbose bool) *DebugMiddleware

NewDebugMiddleware provides middleware suitable for exhaustive request/response logging.

func (*DebugMiddleware) ServeHTTP

func (l *DebugMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Seeder

type Seeder interface {
	HashKey() []byte
	BlockKey() []byte
}

Seeder describes functions needed for encrypted cookies.

func NewDefaultSeeder

func NewDefaultSeeder() (Seeder, error)

NewDefaultSeeder creates random default values for the Seeder. This is only good for one execution run, unless the generated keys are persisted.

func NewSeeder

func NewSeeder(hash string, block string) (Seeder, error)

NewSeeder creates a default Seeder from base64 encoded seed values.

Jump to

Keyboard shortcuts

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