Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

session_memory

v0.0.0-20240711162211-159a3375b30a
taylz.io/http/session/storage/memory

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

19 matches

Top ↑

Functions

BearerReader

func BearerReader(s *Service) session.HTTPReader

CookieReader

func CookieReader(s *Service) session.HTTPReader

Types

Cache

type Cache = maps.Observable[string, *session.T]

NewCache

func NewCache() *Cache

Service

type Service struct {
	Settings
	// contains filtered or unexported fields
}

Service implements Manager with a *Cache

NewService

func NewService(settings Settings, keygen func() string, readerBuilder func(*Service) session.HTTPReader) *Service

NewService creates a Service

Service.Delete

func (s *Service) Delete(id string)

Delete removes a Session

Service.Get

func (s *Service) Get(id string) *session.T

Get returns a Session by ID

Service.Must

func (s *Service) Must(name string) (t *session.T)

Must refreshes and returns the Session with the given username if one exists, and creates one if necessary

Service.Observe

func (s *Service) Observe(f session.Observer)

Observe adds an Observer

Service.ReadHTTP

func (s *Service) ReadHTTP(r *http.Request) (t *session.T, err error)

Service.Size

func (s *Service) Size() int

Size returns the current len of the map

Service.Update

func (s *Service) Update(id string) (err error)

Update changes the internal expiry time of a Session

Service.WriteHTTP

func (s *Service) WriteHTTP(w http.Writer, t *session.T)

WriteHTTP writes the Set-Cookie header

Settings

type Settings struct {
	CookieID string
	Domain   string
	Path     string
	SameSite string
	Secure   bool
	HttpOnly bool
	Lifetime time.Duration
	GC       time.Duration
}

Settings is configuration for sessions

DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns Settings for using in a basic case

NewSettings

func NewSettings(cookieID, domain, path, sameSite string, secure, httpOnly bool, lifetime, gc time.Duration) Settings

NewSettings creates Settings

Dependency graph