Documentation
¶
Index ¶
- Variables
- func Config(ctx context.Context) *system.Config
- func ErrorMessage(err error) i18n.Message
- func ErrorStatus(err error) int
- func Locale(ctx context.Context) string
- func NewFileServer(mux *router.ServeMux, renderer *Renderer, errorHandler FileServerErrorHandler) http.HandlerFunc
- func NewTemplateFuncs(custom template.FuncMap) template.FuncMap
- func TmplAdd(values ...any) (int, error)
- func TmplAddf(values ...any) (float64, error)
- func TmplAtoi(a string) int
- func TmplContrastColor(color string) string
- func TmplDiv(values ...any) (int, error)
- func TmplDivf(values ...any) (float64, error)
- func TmplFields(str string) []string
- func TmplFormatDuration(d time.Duration) string
- func TmplFormatDurationStat(d time.Duration) string
- func TmplFormatSizeIEC(bytes any, prec int) (string, error)
- func TmplFormatSizeSI(bytes any, prec int) (string, error)
- func TmplFormatTime(t time.Time, format string) string
- func TmplGetOr(src any, key string, fallback any) any
- func TmplHasPrefix(value, prefix any) bool
- func TmplHasString(haystack []string, value any) bool
- func TmplHasSuffix(value, suffix any) bool
- func TmplInts(start, end int) []int
- func TmplJoin(strs []string, sep string) string
- func TmplLast(strs []string) string
- func TmplMap(pairs ...any) (map[string]any, error)
- func TmplMarshalIndentJSON(value any, prefix, indent string) (string, error)
- func TmplMarshalJSON(value any) (string, error)
- func TmplMax(values ...any) (int, error)
- func TmplMaxf(values ...any) (float64, error)
- func TmplMin(values ...any) (int, error)
- func TmplMinf(values ...any) (float64, error)
- func TmplMod(values ...any) (int, error)
- func TmplMul(values ...any) (int, error)
- func TmplMulf(values ...any) (float64, error)
- func TmplNeg(x any) (int, error)
- func TmplNegf(x any) (float64, error)
- func TmplQueryReplace(q url.Values, pairs ...any) (template.URL, error)
- func TmplQueryString(q url.Values) template.URL
- func TmplReplaceAll(value any, old, new string) string
- func TmplSlice(elements ...any) []any
- func TmplSliceContains(haystack []any, needle any) bool
- func TmplSplit(str, sep string) []string
- func TmplStatusText(code int) string
- func TmplSub(values ...any) (int, error)
- func TmplSubf(values ...any) (float64, error)
- func TmplTimeSince(t time.Time) time.Duration
- func TmplTitleASCII(value any) string
- func TmplToLower(value any) string
- func TmplToStrings(value any) ([]string, error)
- func TmplToUpper(value any) string
- func TmplTrimPrefix(value, prefix any) string
- func TmplTrimSuffix(value, suffix any) string
- func TmplUnescapeCSS(s string) template.CSS
- func TmplUnescapeHTML(s string) template.HTML
- func TmplUnescapeHTMLAttr(s string) template.HTMLAttr
- func TmplUnescapeJS(s string) template.JS
- func User(ctx context.Context) *account.User
- type AccountReader
- type AppData
- type AssetPipeline
- func (a *AssetPipeline) CSSLinks() string
- func (a *AssetPipeline) HTMLTemplates() string
- func (a *AssetPipeline) JSImportMap() string
- func (a *AssetPipeline) JSImports() string
- func (a *AssetPipeline) Load(asset string, args ...string) any
- func (a *AssetPipeline) Prefetch(asset string) string
- func (a *AssetPipeline) Prefetches() string
- func (a *AssetPipeline) Preload(asset string) string
- func (a *AssetPipeline) Preloads() string
- func (a *AssetPipeline) Tag(asset string) string
- func (a *AssetPipeline) TagJSImport(asset string) string
- func (a *AssetPipeline) WriteCSSLinks() template.HTML
- func (a *AssetPipeline) WriteHTMLTemplates() template.HTML
- func (a *AssetPipeline) WriteJSImportMap() template.HTML
- func (a *AssetPipeline) WriteJSImports() template.HTML
- func (a *AssetPipeline) WritePrefetches() template.HTML
- func (a *AssetPipeline) WritePreloads() template.HTML
- type BackupOptions
- type CSRF
- type FileServerErrorHandler
- type Form
- type GuardPredicateFunc
- type Handler
- func (h *Handler) AttachContext(next http.HandlerFunc) http.HandlerFunc
- func (h *Handler) AttachContextLogger(next http.HandlerFunc) http.HandlerFunc
- func (h *Handler) Config(ctx context.Context) *system.Config
- func (h *Handler) Locale(ctx context.Context) string
- func (h *Handler) Logger(ctx context.Context) *slog.Logger
- func (h *Handler) Passport(ctx context.Context) guard.Passport
- func (h *Handler) PassportByEmail(ctx context.Context, email string) (guard.Passport, error)
- func (h *Handler) PassportByUser(ctx context.Context, user *account.User) guard.Passport
- func (h *Handler) RenewSession(ctx context.Context) ([]byte, error)
- func (h *Handler) SendEmail(ctx context.Context, templateFiles fs.FS, ...) error
- func (h *Handler) SendSMS(ctx context.Context, to, body string) error
- func (h *Handler) SendTOTPSMS(email, tel string) error
- func (h *Handler) Template(files fs.FS, patterns TemplatePatternsFunc, funcs template.FuncMap, ...) *template.Template
- func (h *Handler) User(ctx context.Context) *account.User
- type I18nRuntime
- type LogReader
- type Logger
- type Mux
- type Query
- func (q Query) Contains(key string, value any) bool
- func (q Query) GetAll(key string) []string
- func (q Query) GetAllOr(key string, fallback any) ([]string, error)
- func (q Query) GetOr(key string, fallback any) string
- func (q Query) Replace(pairs ...any) (template.URL, error)
- func (q Query) String() template.URL
- type RateLimitConfig
- type Recovery
- type Renderer
- func (rn *Renderer) Asset(r *http.Request, ap *AssetPipeline, upath string) (string, time.Time, []byte, error)
- func (rn *Renderer) ErrorView(w http.ResponseWriter, r *http.Request, msg string, err error, view string, ...)
- func (rn *Renderer) ErrorViewFunc(w http.ResponseWriter, r *http.Request, msg string, err error, view string, ...)
- func (rn *Renderer) FindAssetByTagged(tagged string) (string, bool)
- func (rn *Renderer) FindTaggedByAsset(asset string) (string, bool)
- func (rn *Renderer) HTML(buf *bytes.Buffer, assetPipeline *AssetPipeline, r *http.Request, status int, ...) error
- func (rn *Renderer) SetViewVars(name string, vars ViewVarsFunc)
- func (rn *Renderer) StreamView(w http.ResponseWriter, r *http.Request, status int, view string, vars Vars) func()
- func (rn *Renderer) TagAsset(key, asset, tagged string)
- func (rn *Renderer) Text(buf *bytes.Buffer, assetPipeline *AssetPipeline, r *http.Request, status int, ...) error
- func (rn *Renderer) View(w http.ResponseWriter, r *http.Request, status int, view string, vars Vars)
- func (rn *Renderer) ViewFunc(w http.ResponseWriter, r *http.Request, status int, view string, ...)
- type RendererConfig
- type Repo
- type RestoreOptions
- type RouterConfig
- type Routers
- type Session
- func (s *Session) DeleteEmail(ctx context.Context)
- func (s *Session) DeleteFlash(ctx context.Context)
- func (s *Session) DeleteFlashError(ctx context.Context)
- func (s *Session) DeleteFlashImportant(ctx context.Context)
- func (s *Session) DeleteFlashWarning(ctx context.Context)
- func (s *Session) DeleteHasActivatedTOTP(ctx context.Context)
- func (s *Session) DeleteHighlightID(ctx context.Context)
- func (s *Session) DeleteImposterUserID(ctx context.Context)
- func (s *Session) DeleteIsAwaitingTOTP(ctx context.Context)
- func (s *Session) DeleteIsSignedIn(ctx context.Context)
- func (s *Session) DeleteKnownPasswordBreachCount(ctx context.Context)
- func (s *Session) DeleteLastSignInAttemptAt(ctx context.Context)
- func (s *Session) DeleteRedirect(ctx context.Context)
- func (s *Session) DeleteSignInAttempts(ctx context.Context)
- func (s *Session) DeleteSortTopID(ctx context.Context)
- func (s *Session) DeleteTOTPMethod(ctx context.Context)
- func (s *Session) DeleteUserID(ctx context.Context)
- func (s *Session) Email(ctx context.Context) string
- func (s *Session) Flash(ctx context.Context) []string
- func (s *Session) FlashError(ctx context.Context) []string
- func (s *Session) FlashImportant(ctx context.Context) []string
- func (s *Session) FlashWarning(ctx context.Context) []string
- func (s *Session) HasActivatedTOTP(ctx context.Context) bool
- func (s *Session) HighlightID(ctx context.Context) int
- func (s *Session) ImposterUserID(ctx context.Context) int
- func (s *Session) IsAwaitingTOTP(ctx context.Context) bool
- func (s *Session) IsSignedIn(ctx context.Context) bool
- func (s *Session) KnownPasswordBreachCount(ctx context.Context) int
- func (s *Session) LastSignInAttemptAt(ctx context.Context) time.Time
- func (s *Session) LastView(ctx context.Context) string
- func (s *Session) PopEmail(ctx context.Context) string
- func (s *Session) PopFlash(ctx context.Context) []string
- func (s *Session) PopFlashError(ctx context.Context) []string
- func (s *Session) PopFlashImportant(ctx context.Context) []string
- func (s *Session) PopFlashWarning(ctx context.Context) []string
- func (s *Session) PopHasActivatedTOTP(ctx context.Context) bool
- func (s *Session) PopHighlightID(ctx context.Context) int
- func (s *Session) PopImposterUserID(ctx context.Context) int
- func (s *Session) PopIsAwaitingTOTP(ctx context.Context) bool
- func (s *Session) PopIsSignedIn(ctx context.Context) bool
- func (s *Session) PopKnownPasswordBreachCount(ctx context.Context) int
- func (s *Session) PopLastSignInAttemptAt(ctx context.Context) time.Time
- func (s *Session) PopLastView(ctx context.Context) string
- func (s *Session) PopRedirect(ctx context.Context) string
- func (s *Session) PopSignInAttempts(ctx context.Context) int
- func (s *Session) PopSortTopID(ctx context.Context) int
- func (s *Session) PopTOTPMethod(ctx context.Context) string
- func (s *Session) PopURLValues(ctx context.Context) url.Values
- func (s *Session) PopUserID(ctx context.Context) int
- func (s *Session) Redirect(ctx context.Context) string
- func (s *Session) SetEmail(ctx context.Context, value string)
- func (s *Session) SetFlash(ctx context.Context, value []string)
- func (s *Session) SetFlashError(ctx context.Context, value []string)
- func (s *Session) SetFlashImportant(ctx context.Context, value []string)
- func (s *Session) SetFlashWarning(ctx context.Context, value []string)
- func (s *Session) SetHasActivatedTOTP(ctx context.Context, value bool)
- func (s *Session) SetHighlightID(ctx context.Context, value int)
- func (s *Session) SetImposterUserID(ctx context.Context, value int)
- func (s *Session) SetIsAwaitingTOTP(ctx context.Context, value bool)
- func (s *Session) SetIsSignedIn(ctx context.Context, value bool)
- func (s *Session) SetKnownPasswordBreachCount(ctx context.Context, value int)
- func (s *Session) SetLastSignInAttemptAt(ctx context.Context, value time.Time)
- func (s *Session) SetLastView(ctx context.Context, value string)
- func (s *Session) SetRedirect(ctx context.Context, value string)
- func (s *Session) SetSignInAttempts(ctx context.Context, value int)
- func (s *Session) SetSortTopID(ctx context.Context, value int)
- func (s *Session) SetTOTPMethod(ctx context.Context, value string)
- func (s *Session) SetURLValues(ctx context.Context, value url.Values)
- func (s *Session) SetUserID(ctx context.Context, value int)
- func (s *Session) SetVisitorID(ctx context.Context, value int64)
- func (s *Session) SignInAttempts(ctx context.Context) int
- func (s *Session) SortTopID(ctx context.Context) int
- func (s *Session) TOTPMethod(ctx context.Context) string
- func (s *Session) URLValues(ctx context.Context) url.Values
- func (s *Session) UserID(ctx context.Context) int
- func (s *Session) VisitorID(ctx context.Context) int64
- type SessionData
- type State
- type Svc
- type SystemReader
- type TFunc
- type TemplateNameFunc
- type TemplatePatternsFunc
- type TemplateProcessFunc
- type Templater
- type Tenant
- type URL
- type Vars
- type ViewData
- type ViewDataFunc
- type ViewErrorFunc
- type ViewVarsFunc
- type WebReadWriter
- type WrapI18nRuntimeFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoIndex = errors.New("no index file")
Functions ¶
func ErrorMessage ¶
func ErrorStatus ¶
func NewFileServer ¶
func NewFileServer(mux *router.ServeMux, renderer *Renderer, errorHandler FileServerErrorHandler) http.HandlerFunc
func TmplContrastColor ¶
func TmplFields ¶
func TmplFormatDuration ¶
func TmplFormatDurationStat ¶
func TmplHasPrefix ¶
func TmplHasString ¶
func TmplHasSuffix ¶
func TmplMarshalIndentJSON ¶
func TmplMarshalJSON ¶
func TmplReplaceAll ¶
func TmplSliceContains ¶
func TmplStatusText ¶
func TmplTitleASCII ¶
func TmplToLower ¶
func TmplToStrings ¶
func TmplToUpper ¶
func TmplTrimPrefix ¶
func TmplTrimSuffix ¶
func TmplUnescapeCSS ¶
func TmplUnescapeHTML ¶
func TmplUnescapeHTMLAttr ¶
func TmplUnescapeJS ¶
Types ¶
type AccountReader ¶
type AccountReader interface {
account.Reader
FindRoleByName(ctx context.Context, name string) (*account.Role, error)
FindRoles(ctx context.Context, sortTopID int) ([]*account.Role, int, error)
FindRolesPageBySearch(ctx context.Context, page, size, sortTopID int, sorts []string, search string) ([]*account.Role, int, error)
CountUsersByRoleID(ctx context.Context, roleID int) (int, error)
FindUsersPageBySearch(ctx context.Context, page, size, sortTopID int, sorts []string, search string) ([]*account.User, int, error)
}
type AssetPipeline ¶
type AssetPipeline struct {
// contains filtered or unexported fields
}
func (*AssetPipeline) CSSLinks ¶
func (a *AssetPipeline) CSSLinks() string
func (*AssetPipeline) HTMLTemplates ¶
func (a *AssetPipeline) HTMLTemplates() string
func (*AssetPipeline) JSImportMap ¶
func (a *AssetPipeline) JSImportMap() string
func (*AssetPipeline) JSImports ¶
func (a *AssetPipeline) JSImports() string
func (*AssetPipeline) Prefetch ¶
func (a *AssetPipeline) Prefetch(asset string) string
func (*AssetPipeline) Prefetches ¶
func (a *AssetPipeline) Prefetches() string
func (*AssetPipeline) Preload ¶
func (a *AssetPipeline) Preload(asset string) string
func (*AssetPipeline) Preloads ¶
func (a *AssetPipeline) Preloads() string
func (*AssetPipeline) Tag ¶
func (a *AssetPipeline) Tag(asset string) string
func (*AssetPipeline) TagJSImport ¶
func (a *AssetPipeline) TagJSImport(asset string) string
func (*AssetPipeline) WriteCSSLinks ¶
func (a *AssetPipeline) WriteCSSLinks() template.HTML
func (*AssetPipeline) WriteHTMLTemplates ¶
func (a *AssetPipeline) WriteHTMLTemplates() template.HTML
func (*AssetPipeline) WriteJSImportMap ¶
func (a *AssetPipeline) WriteJSImportMap() template.HTML
func (*AssetPipeline) WriteJSImports ¶
func (a *AssetPipeline) WriteJSImports() template.HTML
func (*AssetPipeline) WritePrefetches ¶
func (a *AssetPipeline) WritePrefetches() template.HTML
func (*AssetPipeline) WritePreloads ¶
func (a *AssetPipeline) WritePreloads() template.HTML
type BackupOptions ¶
type BackupOptions struct {
Database bool
}
type FileServerErrorHandler ¶
type FileServerErrorHandler func(w http.ResponseWriter, r *http.Request, err error)
type GuardPredicateFunc ¶
type Handler ¶
func (*Handler) AttachContext ¶
func (h *Handler) AttachContext(next http.HandlerFunc) http.HandlerFunc
func (*Handler) AttachContextLogger ¶
func (h *Handler) AttachContextLogger(next http.HandlerFunc) http.HandlerFunc
func (*Handler) PassportByEmail ¶
func (*Handler) PassportByUser ¶
func (*Handler) SendTOTPSMS ¶
type I18nRuntime ¶
type RateLimitConfig ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer(config RendererConfig) *Renderer
func (*Renderer) ErrorViewFunc ¶
func (rn *Renderer) ErrorViewFunc(w http.ResponseWriter, r *http.Request, msg string, err error, view string, dataFunc ViewDataFunc)
func (*Renderer) FindAssetByTagged ¶
func (*Renderer) FindTaggedByAsset ¶
func (*Renderer) SetViewVars ¶
func (rn *Renderer) SetViewVars(name string, vars ViewVarsFunc)
func (*Renderer) StreamView ¶
func (*Renderer) ViewFunc ¶
func (rn *Renderer) ViewFunc(w http.ResponseWriter, r *http.Request, status int, view string, dataFunc ViewDataFunc)
type RendererConfig ¶
type RendererConfig struct {
Handler *Handler
AssetTags *cache.Cache[string, string]
AssetFiles fs.FS
TemplateFiles fs.FS
TemplatePatterns TemplatePatternsFunc
TemplateName TemplateNameFunc
Funcs template.FuncMap
T TFunc
WrapI18nRuntime WrapI18nRuntimeFunc
Process TemplateProcessFunc
ViewErrorFunc ViewErrorFunc
}
type Repo ¶
type Repo struct {
Account AccountReader
Log LogReader
System SystemReader
Web WebReadWriter
}
type RestoreOptions ¶
type RouterConfig ¶
type RouterConfig struct {
RateLimit RateLimitConfig
}
type Routers ¶
type Routers struct {
Site RouterConfig
PWA RouterConfig
APIv1 RouterConfig
}
type Session ¶
func (*Session) DeleteEmail ¶
func (*Session) DeleteFlash ¶
func (*Session) DeleteFlashError ¶
func (*Session) DeleteFlashImportant ¶
func (*Session) DeleteFlashWarning ¶
func (*Session) DeleteHasActivatedTOTP ¶
func (*Session) DeleteHighlightID ¶
func (*Session) DeleteImposterUserID ¶
func (*Session) DeleteIsAwaitingTOTP ¶
func (*Session) DeleteIsSignedIn ¶
func (*Session) DeleteKnownPasswordBreachCount ¶
func (*Session) DeleteLastSignInAttemptAt ¶
func (*Session) DeleteRedirect ¶
func (*Session) DeleteSignInAttempts ¶
func (*Session) DeleteSortTopID ¶
func (*Session) DeleteTOTPMethod ¶
func (*Session) DeleteUserID ¶
func (*Session) KnownPasswordBreachCount ¶
func (*Session) LastSignInAttemptAt ¶
func (*Session) PopFlashImportant ¶
func (*Session) PopHasActivatedTOTP ¶
func (*Session) PopKnownPasswordBreachCount ¶
func (*Session) PopLastSignInAttemptAt ¶
func (*Session) SetFlashError ¶
func (*Session) SetFlashImportant ¶
func (*Session) SetFlashWarning ¶
func (*Session) SetHasActivatedTOTP ¶
func (*Session) SetImposterUserID ¶
func (*Session) SetIsAwaitingTOTP ¶
func (*Session) SetKnownPasswordBreachCount ¶
func (*Session) SetLastSignInAttemptAt ¶
func (*Session) SetSignInAttempts ¶
func (*Session) SetURLValues ¶
type SessionData ¶
type SessionData struct {
// General session keys
Flash []string
FlashWarning []string
FlashImportant []string
FlashError []string
Redirect string
HighlightID int
// Account session keys
ImposterUserID int
UserID int
Email string
TOTPMethod string
HasActivatedTOTP bool
IsAwaitingTOTP bool
IsSignedIn bool
KnownPasswordBreachCount int
}
type SystemReader ¶
type TemplateNameFunc ¶
type TemplatePatternsFunc ¶
type TemplateProcessFunc ¶
type TemplateProcessFunc func(w http.ResponseWriter, r *http.Request)
type Tenant ¶
type Tenant struct {
Key string
Kind string
Scheme string
Host string
Hosts map[string]string
DataDir string
Dev bool
Env string
Insecure bool
IPWhitelist []string
Proxies []string
SMTPEnvelopeFrom string
SMTPHeaderFrom string
Secret []byte
Flag *flag.Provider
Broker event.Broker
Email smtp.Mailer
Logger *slog.Logger
Metrics *expvar.Map
Svc Svc
Repo Repo
Recovery Recovery
SuperRole *account.Role
}
type ViewData ¶
type ViewData struct {
Asset *AssetPipeline
View string
Stream string
Status int
CSRF CSRF
Locale string
I18nRuntime i18n.Runtime
ErrorMessage string
Errors errsx.Map
Now time.Time
Env string
Flag *flag.Provider
Form Form
URL URL
App AppData
Session SessionData
Config *system.Config
User *account.User
Passport guard.Passport
Props map[string]any
State *State
Log Logger
Vars Vars
}
type ViewDataFunc ¶
type ViewErrorFunc ¶
type WebReadWriter ¶
type WebReadWriter interface {
session.ReadWriter
AddEmailVerificationToken(ctx context.Context, email string, ttl time.Duration) (string, error)
FindEmailVerificationTokenEmail(ctx context.Context, token string) (string, error)
ConsumeEmailVerificationToken(ctx context.Context, token string) error
AddResetPasswordToken(ctx context.Context, email string, ttl time.Duration) (string, error)
FindResetPasswordTokenEmail(ctx context.Context, token string) (string, error)
ConsumeResetPasswordToken(ctx context.Context, token string) error
AddSignInMagicLinkToken(ctx context.Context, email string, ttl time.Duration) (string, error)
FindSignInMagicLinkTokenEmail(ctx context.Context, token string) (string, error)
ConsumeSignInMagicLinkToken(ctx context.Context, token string) error
AddTOTPResetVerifyToken(ctx context.Context, email string, ttl time.Duration) (string, error)
FindTOTPResetVerifyTokenEmail(ctx context.Context, token string) (string, error)
ConsumeTOTPResetVerifyToken(ctx context.Context, token string) error
AddResetTOTPToken(ctx context.Context, email string, ttl time.Duration) (string, error)
FindResetTOTPTokenEmail(ctx context.Context, token string) (string, error)
ConsumeResetTOTPToken(ctx context.Context, token string) error
AddDomainEvent(ctx context.Context, kind, name, imposter, data string, createdAt time.Time) error
FindDomainEventsPageBySearch(ctx context.Context, page, size int, search string) ([]*web.DomainEvent, int, error)
}
type WrapI18nRuntimeFunc ¶
func NewI18nRuntimeWrapper ¶
func NewI18nRuntimeWrapper(mux Mux) WrapI18nRuntimeFunc
Click to show internal directories.
Click to hide internal directories.