Documentation
¶
Index ¶
- Variables
- func ErrorMessage(err error) i18n.Message
- func ErrorStatus(err error) int
- 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 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) (string, error)
- func TmplFormatSizeSI(bytes any) (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 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 TmplToStrings(value any) ([]string, error)
- func TmplTrimPrefix(value, prefix any) string
- func TmplTrimSuffix(value, suffix any) string
- func TmplUnescapeHTML(s string) template.HTML
- func TmplUnescapeHTMLAttr(s string) template.HTMLAttr
- func TmplUnescapeJS(s string) template.JS
- 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 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 Logger
- type Mux
- type Query
- 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 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) 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) 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) 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) 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) 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
- type SessionData
- type State
- type Svc
- type SystemReader
- type TFunc
- 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 TmplFields ¶
func TmplFormatDuration ¶
func TmplFormatDurationStat ¶
func TmplFormatSizeIEC ¶
func TmplFormatSizeSI ¶
func TmplHasPrefix ¶
func TmplHasString ¶
func TmplHasSuffix ¶
func TmplMarshalIndentJSON ¶
func TmplMarshalJSON ¶
func TmplReplaceAll ¶
func TmplSliceContains ¶
func TmplStatusText ¶
func TmplToStrings ¶
func TmplTrimPrefix ¶
func TmplTrimSuffix ¶
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 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 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
Funcs template.FuncMap
T TFunc
WrapI18nRuntime WrapI18nRuntimeFunc
Process TemplateProcessFunc
ViewErrorFunc ViewErrorFunc
}
type Repo ¶
type Repo struct {
Account AccountReader
System SystemReader
Web WebReadWriter
}
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) 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) 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
UserID int
Email string
TOTPMethod string
HasActivatedTOTP bool
IsAwaitingTOTP bool
IsSignedIn bool
KnownPasswordBreachCount int
}
type SystemReader ¶
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
Data string
Dev bool
Insecure bool
IPWhitelist []string
Proxies []string
SMTPEnvelopeFrom string
Broker event.Broker
Email smtp.Mailer
Logger *slog.Logger
Metrics *expvar.Map
Svc Svc
Repo Repo
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
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
LogDomainEvent(ctx context.Context, kind, name, data string, createdAt time.Time) error
}
type WrapI18nRuntimeFunc ¶
func NewI18nRuntimeWrapper ¶
func NewI18nRuntimeWrapper(mux Mux) WrapI18nRuntimeFunc
Click to show internal directories.
Click to hide internal directories.