Documentation ¶
Index ¶
- Constants
- func ValidateNamespace(name string) error
- type InMemoryStore
- type Manager
- func (man *Manager) ContextKey() contextKey
- func (man *Manager) CreateCookie(sessionID string) (http.Cookie, error)
- func (man *Manager) CreateSession() Session
- func (man *Manager) DeleteSession(sessionID string) error
- func (man *Manager) GetSession(sessionID string) (Session, error)
- func (man *Manager) InvalidateSession(sessionID string) error
- func (man *Manager) Middleware(next http.Handler) http.Handler
- func (man *Manager) PopulateRequestContext(r *http.Request, session Session) *http.Request
- func (man *Manager) RenewSession(sessionID string) (Session, error)
- func (man *Manager) SaveSession(sessonInstance Session) error
- func (man *Manager) UpdateSession(sessionID string, sessionInstance Session) error
- type Session
- type Storer
Constants ¶
const ( INVALID int = iota VALID )
Variables ¶
This section is empty.
Functions ¶
func ValidateNamespace ¶ added in v0.2.0
Types ¶
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore is an in-memory implementation of the Storer interface.
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore creates a new instance of InMemoryStore.
func (*InMemoryStore) Delete ¶
func (s *InMemoryStore) Delete(sessionID string) error
delete deletes session data from the in-memory store.
func (*InMemoryStore) Get ¶
func (s *InMemoryStore) Get(sessionID string) (Session, error)
get retrieves session data from the in-memory store.
func (*InMemoryStore) Save ¶
func (s *InMemoryStore) Save(session Session) error
save saves a session into the in-memory store.
type Manager ¶ added in v0.2.0
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) ContextKey ¶ added in v0.2.0
func (man *Manager) ContextKey() contextKey
acts as an accessor to get the manager's context key as it must not be changed
func (*Manager) CreateCookie ¶ added in v0.2.0
creates and returns a new cookie using a session
func (*Manager) CreateSession ¶ added in v0.2.0
create a new session and add it to the store.
func (*Manager) DeleteSession ¶ added in v0.2.0
a wrapper over the delete method in the store
func (*Manager) GetSession ¶ added in v0.2.0
func (*Manager) InvalidateSession ¶ added in v0.2.0
mark the session as invalid but keep it around until the session expiry time elapses by this time the associated cookie should have also expired then the session can be deleted
func (*Manager) Middleware ¶ added in v0.2.0
populates the contexts of new requests with the sessions to which the request cookie points. The middleware also extends the session idle times after each request
func (*Manager) PopulateRequestContext ¶ added in v0.2.0
fill the request context with the given session and returns the updated request
func (*Manager) RenewSession ¶ added in v0.2.0
change the session id of the session but maintain the data therein
func (*Manager) SaveSession ¶ added in v0.2.0
type Storer ¶
type Storer interface { // retrieve the sesison data from the underlying container // and decode it before returning it to the calling function Get(sessionID string) (Session, error) // save an encoded form of the given session data into // the underlying container Save(session Session) error // delete the session identified by the given sessionID Delete(sessionID string) error // update parts of the session that identifes with the given sessionID: // the new session is used to replace the old session hance, // using this function requires that a pointer to the updated // copy of the old session is created an passed to this function. Update(sessionID string, newSession Session) error }