sessions

package module
v0.0.0-...-7047d39 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2018 License: Apache-2.0 Imports: 8 Imported by: 7 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(id string) 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 (z *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 (z *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

func (*Session) GetFloat

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

GetFloat return float64 value

func (*Session) GetFloats

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

GetFloats return array float64 value

func (*Session) GetInt

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

GetInt return int64 value

func (*Session) GetInts

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

GetInts return array int64 value

func (*Session) GetString

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

GetString return string value

func (*Session) GetStrings

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

GetStrings return array string value

func (*Session) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (*Session) Msgsize

func (z *Session) Msgsize() (s 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 (z *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
⌂ 换网址