db

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const MaxAge = 60 * 60 * 24 * 365 * 5

Variables

View Source
var (
	ErrDrop = errors.New("event dropped")
)

Functions

This section is empty.

Types

type Config

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

func Open

func Open(db *shards.DB, startDomains []string) (*Config, error)

func (*Config) Authorize

func (c *Config) Authorize(w http.ResponseWriter, r *http.Request) bool

func (*Config) Close

func (db *Config) Close() error

func (*Config) Context

func (c *Config) Context(base map[string]any) map[string]any

func (*Config) CurrentSite

func (c *Config) CurrentSite() *v1.Site

func (*Config) CurrentUser

func (c *Config) CurrentUser() string

func (*Config) Flash

func (c *Config) Flash(w http.ResponseWriter)

func (*Config) HTML

func (db *Config) HTML(w http.ResponseWriter, t *template.Template, data map[string]any)

func (*Config) HTMLCode

func (db *Config) HTMLCode(code int, w http.ResponseWriter, t *template.Template, data map[string]any)

func (*Config) IsLoggedOut

func (c *Config) IsLoggedOut(w http.ResponseWriter) bool

func (*Config) IsValidCsrf

func (c *Config) IsValidCsrf(r *http.Request) bool

func (*Config) JSON

func (db *Config) JSON(w http.ResponseWriter, data any)

func (*Config) JSONCode

func (db *Config) JSONCode(code int, w http.ResponseWriter, data any)

func (*Config) Load

func (c *Config) Load(w http.ResponseWriter, r *http.Request)

func (*Config) LoadSharedLinkSession

func (db *Config) LoadSharedLinkSession(r *http.Request, name string) time.Time

func (*Config) Location added in v1.8.0

func (db *Config) Location() *location.Location

func (*Config) Logger

func (db *Config) Logger() *slog.Logger

func (*Config) Login

func (c *Config) Login(w http.ResponseWriter) string

func (*Config) Logout

func (c *Config) Logout(w http.ResponseWriter)

func (*Config) Ops added in v1.5.1

func (db *Config) Ops() *ops.Ops

func (*Config) PasswordMatch added in v1.3.0

func (db *Config) PasswordMatch(pwd string) bool

func (*Config) Pebble added in v1.5.1

func (db *Config) Pebble() *pebble.DB

func (*Config) ProcessEvent

func (db *Config) ProcessEvent(r *http.Request) error

func (*Config) SaveCsrf

func (c *Config) SaveCsrf(w http.ResponseWriter)

func (*Config) SaveSession

func (c *Config) SaveSession(w http.ResponseWriter)

func (*Config) SaveSharedLinkSession

func (db *Config) SaveSharedLinkSession(w http.ResponseWriter, name string)

func (*Config) SaveSuccessRegister

func (c *Config) SaveSuccessRegister(w http.ResponseWriter, uid uuid.UUID)

func (*Config) SessionTimeout

func (c *Config) SessionTimeout(w http.ResponseWriter)

func (*Config) SetSite

func (c *Config) SetSite(site *v1.Site)

func (*Config) Start

func (db *Config) Start(ctx context.Context)

func (*Config) Success added in v1.1.0

func (c *Config) Success(msg string)

func (*Config) TimeSeries added in v1.5.1

func (db *Config) TimeSeries() *timeseries.Timeseries

func (*Config) Wrap

func (c *Config) Wrap(kind string) func(f func(db *Config, w http.ResponseWriter, r *http.Request)) http.HandlerFunc

type Data

type Data struct {
	TimeoutAt     time.Time `json:",omitempty"`
	LastSeen      time.Time `json:",omitempty"`
	Flash         Flash     `json:",omitempty"`
	CurrentUserID string    `json:",omitempty"`
	Csrf          string    `json:",omitempty"`
	LoginDest     string    `json:",omitempty"`
	LoggedIn      bool      `json:",omitempty"`
}

type Flash

type Flash map[string]map[string]string

func (Flash) Error

func (f Flash) Error(msg string)

func (Flash) Success

func (f Flash) Success(msg string)

type Request

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

func (*Request) Parse

func (rq *Request) Parse(r *http.Request) error

func (*Request) Release

func (r *Request) Release()

type SessionContext

type SessionContext struct {
	Data Data
	// contains filtered or unexported fields
}

func (*SessionContext) FailFlash

func (s *SessionContext) FailFlash(m string) *SessionContext

func (*SessionContext) Load

func (s *SessionContext) Load(r *http.Request) error

func (*SessionContext) LoadBase

func (s *SessionContext) LoadBase(r *http.Request, name string) ([]byte, error)
func (s *SessionContext) SaveSharedLink(w http.ResponseWriter, name string) error

func (*SessionContext) SuccessFlash

func (s *SessionContext) SuccessFlash(m string) *SessionContext

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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