session: gitea.com/tango/session Index | Files

package session

import "gitea.com/tango/session"

Index

Package Files

generator.go memorystore.go session.go sessions.go store.go tracker.go

Constants

const (
    DefaultMaxAge        = 30 * time.Minute
    DefaultSessionIdName = "SESSIONID"
    DefaultCookiePath    = "/"
)

func GenRandKey Uses

func GenRandKey(strength int) []byte

type CookieTracker Uses

type CookieTracker struct {
    Name     string
    MaxAge   time.Duration
    Lock     sync.Mutex
    Secure   bool
    RootPath string
    Domain   string
}

CookieTracker provide sessionid from cookie

func NewCookieTracker Uses

func NewCookieTracker(name string, maxAge time.Duration, secure bool, rootPath string) *CookieTracker

func (*CookieTracker) Clear Uses

func (tracker *CookieTracker) Clear(rw http.ResponseWriter)

func (*CookieTracker) Get Uses

func (tracker *CookieTracker) Get(req *http.Request) (Id, error)

func (*CookieTracker) Set Uses

func (tracker *CookieTracker) Set(req *http.Request, rw http.ResponseWriter, id Id)

func (*CookieTracker) SetMaxAge Uses

func (tracker *CookieTracker) SetMaxAge(maxAge time.Duration)

type CookieUrlTracker Uses

type CookieUrlTracker struct {
    CookieTracker
}

func NewCookieUrlTracker Uses

func NewCookieUrlTracker(name string, maxAge time.Duration, secure bool, rootPath string) *CookieUrlTracker

for SWFUpload ...

func (*CookieUrlTracker) Get Uses

func (tracker *CookieUrlTracker) Get(req *http.Request) (Id, error)

type HeaderTracker Uses

type HeaderTracker struct {
    Name string
}

func NewHeaderTracker Uses

func NewHeaderTracker(name string) *HeaderTracker

func (*HeaderTracker) Clear Uses

func (tracker *HeaderTracker) Clear(rw http.ResponseWriter)

func (*HeaderTracker) Get Uses

func (tracker *HeaderTracker) Get(req *http.Request) (Id, error)

func (*HeaderTracker) Set Uses

func (tracker *HeaderTracker) Set(req *http.Request, rw http.ResponseWriter, id Id)

func (*HeaderTracker) SetMaxAge Uses

func (tracker *HeaderTracker) SetMaxAge(maxAge time.Duration)

type Id Uses

type Id string

type IdGenerator Uses

type IdGenerator interface {
    Gen(req *http.Request) Id
    IsValid(id Id) bool
}

type MemoryStore Uses

type MemoryStore struct {
    GcInterval time.Duration
    // contains filtered or unexported fields
}

func NewMemoryStore Uses

func NewMemoryStore(maxAge time.Duration) *MemoryStore

func (*MemoryStore) Add Uses

func (store *MemoryStore) Add(id Id) bool

func (*MemoryStore) Clear Uses

func (store *MemoryStore) Clear(id Id) bool

func (*MemoryStore) Del Uses

func (store *MemoryStore) Del(id Id, key string) bool

func (*MemoryStore) Exist Uses

func (store *MemoryStore) Exist(id Id) bool

func (*MemoryStore) Get Uses

func (store *MemoryStore) Get(id Id, key string) interface{}

func (*MemoryStore) Run Uses

func (store *MemoryStore) Run() error

func (*MemoryStore) Set Uses

func (store *MemoryStore) Set(id Id, key string, value interface{}) error

func (*MemoryStore) SetIdMaxAge Uses

func (store *MemoryStore) SetIdMaxAge(id Id, maxAge time.Duration)

func (*MemoryStore) SetMaxAge Uses

func (store *MemoryStore) SetMaxAge(maxAge time.Duration)

type Options Uses

type Options struct {
    MaxAge           time.Duration
    SessionIdName    string
    Store            Store
    Generator        IdGenerator
    Tracker          Tracker
    OnSessionNew     func(*Session)
    OnSessionRelease func(*Session)
}

type Session Uses

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

func (*Session) Del Uses

func (session *Session) Del(key string) bool

func (*Session) Get Uses

func (session *Session) Get(key string) interface{}

func (*Session) GetSession Uses

func (session *Session) GetSession() *Session

func (*Session) Id Uses

func (session *Session) Id() Id

func (*Session) InitSession Uses

func (session *Session) InitSession(manager *Sessions, req *http.Request, rw http.ResponseWriter) error

func (*Session) IsValid Uses

func (session *Session) IsValid() bool

func (*Session) Release Uses

func (session *Session) Release()

func (*Session) Sessions Uses

func (session *Session) Sessions() *Sessions

func (*Session) Set Uses

func (session *Session) Set(key string, value interface{})

func (*Session) SetId Uses

func (session *Session) SetId(id Id)

func (*Session) SetMaxAge Uses

func (session *Session) SetMaxAge(maxAge time.Duration)

type Sessioner Uses

type Sessioner interface {
    GetSession() *Session
    InitSession(*Sessions, *http.Request, http.ResponseWriter) error
}

Sessioner Session interface

type Sessions Uses

type Sessions struct {
    Options
}

func Default Uses

func Default() *Sessions

func New Uses

func New(opts ...Options) *Sessions

func NewWithTimeout Uses

func NewWithTimeout(maxAge time.Duration) *Sessions

func (*Sessions) Exist Uses

func (manager *Sessions) Exist(id Id) bool

func (*Sessions) Handle Uses

func (itor *Sessions) Handle(ctx *tango.Context)

func (*Sessions) Invalidate Uses

func (manager *Sessions) Invalidate(rw http.ResponseWriter, session *Session)

func (*Sessions) Run Uses

func (manager *Sessions) Run() error

func (*Sessions) Session Uses

func (manager *Sessions) Session(req *http.Request, rw http.ResponseWriter) *Session

func (*Sessions) SessionFromID Uses

func (manager *Sessions) SessionFromID(id Id) *Session

func (*Sessions) SetIdMaxAge Uses

func (manager *Sessions) SetIdMaxAge(id Id, maxAge time.Duration)

func (*Sessions) SetMaxAge Uses

func (manager *Sessions) SetMaxAge(maxAge time.Duration)

type Sessionser Uses

type Sessionser interface {
    SetSessions(*Sessions)
}

type Sha1Generator Uses

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

func NewSha1Generator Uses

func NewSha1Generator(hashKey string) *Sha1Generator

func (*Sha1Generator) Gen Uses

func (gen *Sha1Generator) Gen(req *http.Request) Id

func (*Sha1Generator) IsValid Uses

func (gen *Sha1Generator) IsValid(id Id) bool

type Store Uses

type Store interface {
    Add(id Id) bool
    Exist(id Id) bool
    Clear(id Id) bool

    Get(id Id, key string) interface{}
    Set(id Id, key string, value interface{}) error
    Del(id Id, key string) bool

    SetMaxAge(maxAge time.Duration)
    SetIdMaxAge(id Id, maxAge time.Duration)

    Run() error
}

type Tracker Uses

type Tracker interface {
    SetMaxAge(maxAge time.Duration)
    Get(req *http.Request) (Id, error)
    Set(req *http.Request, rw http.ResponseWriter, id Id)
    Clear(rw http.ResponseWriter)
}

Tracker provide and set sessionid

type UrlTracker Uses

type UrlTracker struct {
    Key         string
    ReplaceLink bool
}

UrlTracker provide sessionid from url

func NewUrlTracker Uses

func NewUrlTracker(key string, replaceLink bool) *UrlTracker

func (*UrlTracker) Clear Uses

func (tracker *UrlTracker) Clear(rw http.ResponseWriter)

func (*UrlTracker) Get Uses

func (tracker *UrlTracker) Get(req *http.Request) (Id, error)

func (*UrlTracker) Set Uses

func (tracker *UrlTracker) Set(req *http.Request, rw http.ResponseWriter, id Id)

func (*UrlTracker) SetMaxAge Uses

func (tracker *UrlTracker) SetMaxAge(maxAge time.Duration)

Package session imports 11 packages (graph) and is imported by 1 packages. Updated 2019-11-08. Refresh now. Tools for package owners.