session

package
v0.0.0-...-bd2df9c Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextKey

type ContextKey string

ContextKey is the key used to store the session in the request context.

const (
	CookieName            = "session"
	SessionKey ContextKey = "session"
)

type Manager

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

Manager represents a session manager.

func NewManager

func NewManager(cookie *securecookie.SecureCookie, queries *db.Queries) *Manager

NewManager returns a new session manager.

func (*Manager) Delete

func (m *Manager) Delete(w http.ResponseWriter, r *http.Request) error

Delete deletes the session for the given request.

func (*Manager) Get

func (m *Manager) Get(r *http.Request) (string, error)

Get gets the session for the given request.

func (*Manager) GetUser

func (m *Manager) GetUser(r *http.Request) (User, error)

GetUser gets the user for the given request.

func (*Manager) Set

func (m *Manager) Set(w http.ResponseWriter, r *http.Request, userID uuid.UUID) error

Set sets a session for the given user.

type User

type User struct {
	ID       uuid.UUID
	Avatar   string
	Email    string
	Username string
}

User represents a user in a session.

Jump to

Keyboard shortcuts

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