sessions

package
v0.0.0-...-11dc724 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCookie

func NewCookie(name, value string, options *Options) *http.Cookie

Types

type MemoryStore

type MemoryStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(session *Session, _ http.ResponseWriter) error

func (*MemoryStore) Get

func (s *MemoryStore) Get(id string, buf *bytes.Buffer) error

func (*MemoryStore) Save

func (s *MemoryStore) Save(session *Session, buf *bytes.Buffer, w http.ResponseWriter) error

type Options

type Options struct {
	Path   string
	Domain string
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
	// MaxAge>0 means Max-Age attribute present and given in seconds.
	MaxAge   int
	Secure   bool
	HttpOnly bool
}

type Session

type Session struct {
	ID      string                 `msg:"-"`
	Values  map[string]interface{} `msg:"v"`
	Options *Options               `msg:"-"`
	IsNew   bool                   `msg:"-"`
	// contains filtered or unexported fields
}

func (*Session) AddFlash

func (s *Session) AddFlash(value string)

AddFlash adds a flash message to the session.

A single variadic argument is accepted, and it is optional: it defines the flash key. If not defined "_flash" is used by default.

func (*Session) AddFlashs

func (s *Session) AddFlashs(values []string)

func (*Session) DecodeMsg

func (s *Session) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Session) Delete

func (s *Session) Delete(w http.ResponseWriter) error

func (*Session) EncodeMsg

func (s *Session) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Session) Flashes

func (s *Session) Flashes() []string

Flashes returns a slice of flash messages from the session.

A single variadic argument is accepted, and it is optional: it defines the flash key. If not defined "_flash" is used by default.

func (*Session) GetBool

func (s *Session) GetBool(key string, def bool) bool

GetBool return bool value from session

func (*Session) GetFloat

func (s *Session) GetFloat(key string, def float64) float64

GetFloat return float64 value from session

func (*Session) GetFloats

func (s *Session) GetFloats(key string, def []float64) []float64

GetFloats return array of float64 from session

func (*Session) GetInt

func (s *Session) GetInt(key string, def int64) int64

GetInt return int64 value from session

func (*Session) GetInts

func (s *Session) GetInts(key string, def []int64) []int64

GetInts return array of int64 from session

func (*Session) GetString

func (s *Session) GetString(key string, def string) string

GetString return string value from session

func (*Session) GetStrings

func (s *Session) GetStrings(key string, def []string) []string

GetStrings return string array from session

func (*Session) MarshalMsg

func (s *Session) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Session) Msgsize

func (s *Session) Msgsize() (sz int)

func (*Session) Name

func (s *Session) Name() string

func (*Session) Save

func (s *Session) Save(w http.ResponseWriter) error

func (*Session) Set

func (s *Session) Set(key string, v interface{})

func (*Session) SetAll

func (s *Session) SetAll(vals map[string]interface{})

func (*Session) UnmarshalMsg

func (s *Session) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SessionManager

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

func New

func New(poolSize int, store Store, options *Options) *SessionManager

func (*SessionManager) Close

func (s *SessionManager) Close(sessions *Sessions)

func (*SessionManager) GetSessions

func (s *SessionManager) GetSessions(r *http.Request) *Sessions

type Sessions

type Sessions struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Sessions) Delete

func (s *Sessions) Delete(w http.ResponseWriter) error

func (*Sessions) Get

func (s *Sessions) Get(name string) *Session

func (*Sessions) Save

func (s *Sessions) Save(w http.ResponseWriter) error

type Store

type Store interface {
	Get(id string, buf *bytes.Buffer) error
	Save(session *Session, buf *bytes.Buffer, w http.ResponseWriter) error
	Delete(session *Session, w http.ResponseWriter) error
}

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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