session

package module
v0.0.0-...-7245e04 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: MIT Imports: 10 Imported by: 0

README

session

A simple Go library to encrypt data into a cookie and read it back out. Cookie-based sessions made simple.

Documentation

Overview

A straightforward way to keep session data in a cookie. No tricks, just simple calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cryptor

type Cryptor struct {
	SecretKey      []byte
	CookieName     string
	MakeCookieFunc MakeCookieFunc // Make cookie with the specified value
}

func NewSimpleCryptor

func NewSimpleCryptor(secretKey []byte, cookieName string) *Cryptor

func (*Cryptor) Clear

func (sc *Cryptor) Clear(w http.ResponseWriter, r *http.Request)

remove cookie (effectively destroying the session)

func (*Cryptor) Read

func (sc *Cryptor) Read(v interface{}, r *http.Request) error

func (*Cryptor) Write

func (sc *Cryptor) Write(v interface{}, w http.ResponseWriter, r *http.Request) error

seralize and encrypt v and write to cookie

type ErrChecksumFailed

type ErrChecksumFailed string

func (ErrChecksumFailed) Error

func (e ErrChecksumFailed) Error() string

type MakeCookieFunc

type MakeCookieFunc func(w http.ResponseWriter, r *http.Request) *http.Cookie

makes an empty cookie, no value

Jump to

Keyboard shortcuts

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