cookieman

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

Cipher is crypt interface to encrypt/decrypt cookie.

type CookieMan

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

CookieMan manages cookies.

func New

func New(cipher Cipher, defaultOpt CookieOption) *CookieMan

New returns new CookieMan with default cookie option.

func (*CookieMan) Clear

func (c *CookieMan) Clear(w http.ResponseWriter, name string)

Clear clears a cookie with given name.

func (*CookieMan) Get

func (c *CookieMan) Get(r *http.Request, name string) ([]byte, error)

Get returns a cookie with given name.

func (*CookieMan) NewCookieStore

func (c *CookieMan) NewCookieStore(name string, opt *CookieOption) *CookieStore

NewCookieStore returns new CookieStore which mangages cookie whose key is given name and with given cookie option.

func (*CookieMan) Set

func (c *CookieMan) Set(w http.ResponseWriter, name string, value []byte, opt *CookieOption) error

Set sets cookie.

type CookieOption

type CookieOption struct {
	http.Cookie
}

CookieOption represents cookie options.

type CookieStore

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

CookieStore stores a cookie.

func (*CookieStore) Clear

func (cs *CookieStore) Clear(w http.ResponseWriter)

Clear clears the cookie.

func (*CookieStore) Get

func (cs *CookieStore) Get(r *http.Request) ([]byte, error)

Get returns cookie value.

func (*CookieStore) Name

func (cs *CookieStore) Name() string

Name returns the cookie name this CookieStore manages.

func (*CookieStore) Set

func (cs *CookieStore) Set(w http.ResponseWriter, value []byte) error

Set sets cookie value.

Jump to

Keyboard shortcuts

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