Documentation ¶
Index ¶
- Variables
- func LoggerWriter(logger log.Logger) io.Writer
- func NewAuthenticator(identityStore auth.IdentityStore) auth.Authenticator
- func NewCORS(cfg CORSConfig) *cors.Cors
- func NewCaptchaManager(cfg CaptchaConfig, store captchas.Store) *captchas.Manager
- func NewCaptchaStore(cfg RedisConfig) captchas.Store
- func NewDB(cfg DBConfig) (*sqlex.DB, func(), error)
- func NewEnforcer(cfg DBConfig) (*casbin.Enforcer, error)
- func NewFileStore(cfg I18NConfig) i18n.Store
- func NewI18N(cfg I18NConfig, store i18n.Store) (*i18n.Translators, error)
- func NewI18NLanguageParsers(cfg I18NConfig) (parsers []i18n.LanguageParser)
- func NewIdentityStore(db *sqlex.DB, manager *JWTManager) auth.IdentityStore
- func NewLogger(cfg LogConfig) (log.Logger, func(), error)
- func NewMailer(cfg MailerConfig) *mail.Dialer
- func NewMinify() *minify.M
- func NewRenderer(cfg ViewConfig) *jetrenderer.Renderer
- func NewSessionManager(cfg SessionConfig, store scs.Store) *scs.SessionManager
- func NewSessionStore(cfg RedisConfig) scs.Store
- func NewUserManager(identityStore auth.IdentityStore, sessionManager *scs.SessionManager) *users.Manager
- type Application
- func (app *Application) AccessManager() *access.Manager
- func (app *Application) AddFlash(ctx *clevergo.Context, flash Flash)
- func (app *Application) Cache() store.StoreInterface
- func (app *Application) DB() *sqlex.DB
- func (app *Application) Flashes(ctx *clevergo.Context) (flashes Flashes)
- func (app *Application) Logger() log.Logger
- func (app *Application) Mailer() *mail.Dialer
- func (app *Application) Params() Params
- func (app *Application) SessionManager() *scs.SessionManager
- func (app *Application) User(ctx *clevergo.Context) (*users.User, error)
- func (app *Application) UserManager() *users.Manager
- type BeforeRenderEvent
- type CORSConfig
- type CORSMiddleware
- type CSRFConfig
- type CSRFMiddleware
- type CaptchaConfig
- type Config
- type Controller
- type DBConfig
- type ErrorHandler
- type FileStore
- type Flash
- type Flashes
- type GzipMiddleware
- type I18NConfig
- type I18NMiddleware
- type IdentityStore
- type JWTConfig
- type JWTManager
- type LogConfig
- type LoggingMiddleware
- type MailerConfig
- type Map
- type MigrationConfig
- type MinifyMiddleware
- type Option
- func SetAccessManager(manager *access.Manager) Option
- func SetCache(cache store.StoreInterface) Option
- func SetDB(db *sqlex.DB) Option
- func SetLogger(logger log.Logger) Option
- func SetMailer(mailer *mail.Dialer) Option
- func SetParams(ps Params) Option
- func SetSessionManager(manager *scs.SessionManager) Option
- func SetUserManager(m *users.Manager) Option
- type Params
- type RedisConfig
- type Server
- type ServerConfig
- type SessionConfig
- type SessionMiddleware
- type Validatable
- type ViewConfig
- type ViewData
Constants ¶
This section is empty.
Variables ¶
View Source
var MiddlewareSet = wire.NewSet( NewCSRFMiddleware, NewI18NMiddleware, NewCORSMiddleware, NewGzipMiddleware, NewSessionMiddleware, NewMinify, NewMinifyMiddleware, NewLoggingMiddleware, )
Functions ¶
func NewAuthenticator ¶
func NewAuthenticator(identityStore auth.IdentityStore) auth.Authenticator
func NewCORS ¶
func NewCORS(cfg CORSConfig) *cors.Cors
func NewCaptchaManager ¶
func NewCaptchaManager(cfg CaptchaConfig, store captchas.Store) *captchas.Manager
func NewCaptchaStore ¶
func NewCaptchaStore(cfg RedisConfig) captchas.Store
func NewEnforcer ¶
func NewFileStore ¶
func NewFileStore(cfg I18NConfig) i18n.Store
NewFileStore returns a file store with the given directory and decoder.
func NewI18N ¶
func NewI18N(cfg I18NConfig, store i18n.Store) (*i18n.Translators, error)
func NewI18NLanguageParsers ¶
func NewI18NLanguageParsers(cfg I18NConfig) (parsers []i18n.LanguageParser)
func NewIdentityStore ¶
func NewIdentityStore(db *sqlex.DB, manager *JWTManager) auth.IdentityStore
NewIdentityStore returns an identity store instance.
func NewRenderer ¶
func NewRenderer(cfg ViewConfig) *jetrenderer.Renderer
func NewSessionManager ¶
func NewSessionManager(cfg SessionConfig, store scs.Store) *scs.SessionManager
func NewSessionStore ¶
func NewSessionStore(cfg RedisConfig) scs.Store
func NewUserManager ¶
func NewUserManager(identityStore auth.IdentityStore, sessionManager *scs.SessionManager) *users.Manager
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...Option) *Application
func (*Application) AccessManager ¶
func (app *Application) AccessManager() *access.Manager
func (*Application) Cache ¶
func (app *Application) Cache() store.StoreInterface
func (*Application) DB ¶
func (app *Application) DB() *sqlex.DB
func (*Application) Flashes ¶
func (app *Application) Flashes(ctx *clevergo.Context) (flashes Flashes)
func (*Application) Logger ¶
func (app *Application) Logger() log.Logger
func (*Application) Mailer ¶
func (app *Application) Mailer() *mail.Dialer
func (*Application) Params ¶
func (app *Application) Params() Params
func (*Application) SessionManager ¶
func (app *Application) SessionManager() *scs.SessionManager
func (*Application) UserManager ¶
func (app *Application) UserManager() *users.Manager
type BeforeRenderEvent ¶
type BeforeRenderEvent struct { App *Application Context *clevergo.Context View string Vars jet.VarMap Data ViewData }
type CORSConfig ¶
type CORSMiddleware ¶
type CORSMiddleware clevergo.MiddlewareFunc
func NewCORSMiddleware ¶
func NewCORSMiddleware(cfg CORSConfig) CORSMiddleware
type CSRFConfig ¶
type CSRFConfig struct { AuthKey string `koanf:"auth_key"` MaxAge int `koanf:"max_age"` Domain string `koanf:"domain"` Path string `koanf:"path"` Secure bool `koanf:"secure"` HTTPOnly bool `koanf:"http_only"` SameSite int `koanf:"same_site"` RequestHeader string `koanf:"request_header"` FieldName string `koanf:"field_name"` CookieName string `koanf:"cookie_name"` TrustedOrigins []string `koanf:"trusted_origins"` }
type CSRFMiddleware ¶
type CSRFMiddleware clevergo.MiddlewareFunc
func NewCSRFMiddleware ¶
func NewCSRFMiddleware(cfg CSRFConfig) CSRFMiddleware
type CaptchaConfig ¶
type CaptchaConfig struct { Driver string `koanf:"driver"` String struct { Height int `koanf:"height"` Width int `koanf:"width"` Length int `koanf:"length"` } `koanf:"string"` Math struct { Height int `koanf:"height"` Width int `koanf:"width"` NoiseCount int `koanf:"noise_count"` } `koanf:"math"` Chinese struct { Height int `koanf:"height"` Width int `koanf:"width"` Length int `koanf:"length"` } `koanf:"chinese"` Digit struct { Height int `koanf:"height"` Width int `koanf:"width"` Length int `koanf:"length"` } `koanf:"digit"` Audio struct { Length int `koanf:"length"` } `koanf:"audio"` }
type Config ¶
type Config struct { HTTP ServerConfig `koanf:"http"` API ServerConfig `koanf:"api"` Params Params `koanf:"params"` DB DBConfig `koanf:"db"` View ViewConfig `koanf:"view"` Session SessionConfig `koanf:"session"` I18N I18NConfig `koanf:"i18n"` Mailer MailerConfig `koanf:"mailer"` Captcha CaptchaConfig `koanf:"captcha"` Migration MigrationConfig `koanf:"migration"` CORS CORSConfig `koanf:"cors"` CSRF CSRFConfig `koanf:"csrf"` JWT JWTConfig `koanf:"jwt"` Redis RedisConfig `koanf:"redis"` Log LogConfig `koanf:"log"` }
type Controller ¶
type Controller struct {
*Application
}
func NewController ¶
func NewController(app *Application) *Controller
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
func NewErrorHandler ¶
func NewErrorHandler(app *Application) *ErrorHandler
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is a file store.
type GzipMiddleware ¶
type GzipMiddleware clevergo.MiddlewareFunc
func NewGzipMiddleware ¶
func NewGzipMiddleware() GzipMiddleware
type I18NConfig ¶
type I18NMiddleware ¶
type I18NMiddleware clevergo.MiddlewareFunc
func NewI18NMiddleware ¶
func NewI18NMiddleware(translators *i18n.Translators, parsers []i18n.LanguageParser) I18NMiddleware
type IdentityStore ¶
type IdentityStore struct {
// contains filtered or unexported fields
}
IdentityStore is an identity store.
func (*IdentityStore) GetIdentity ¶
func (s *IdentityStore) GetIdentity(id string) (auth.Identity, error)
GetIdentity implements IdentityStore.GetIdentity.
func (*IdentityStore) GetIdentityByToken ¶
func (s *IdentityStore) GetIdentityByToken(token, tokenType string) (auth.Identity, error)
GetIdentityByToken implements IdentityStore.GetIdentityByToken.
type JWTManager ¶
type JWTManager struct {
// contains filtered or unexported fields
}
func NewJWTManager ¶
func NewJWTManager(cfg JWTConfig) *JWTManager
func (*JWTManager) Parse ¶
func (m *JWTManager) Parse(s string) (*jwt.StandardClaims, error)
type LoggingMiddleware ¶
type LoggingMiddleware clevergo.MiddlewareFunc
func NewLoggingMiddleware ¶
func NewLoggingMiddleware() LoggingMiddleware
type MailerConfig ¶
type MailerConfig struct { Host string `koanf:"host"` Port int `koanf:"port"` Username string `koanf:"username"` Password string `koanf:"password"` }
MailerConfig mailer config.
type MigrationConfig ¶
type MinifyMiddleware ¶
type MinifyMiddleware clevergo.MiddlewareFunc
func NewMinifyMiddleware ¶
func NewMinifyMiddleware(m *minify.M) MinifyMiddleware
type Option ¶
type Option func(*Application)
func SetAccessManager ¶
func SetCache ¶
func SetCache(cache store.StoreInterface) Option
func SetSessionManager ¶
func SetSessionManager(manager *scs.SessionManager) Option
func SetUserManager ¶
type RedisConfig ¶
type Server ¶
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
func (*Server) ListenAndServeUnix ¶
type ServerConfig ¶
type SessionConfig ¶
type SessionConfig struct { Lifetime int `koanf:"lifetime"` IdleTimeout int `koanf:"idle_timeout"` CookieName string `koanf:"cookie_name"` CookieDomain string `koanf:"cookie_domain"` CookiePath string `koanf:"cookie_path"` CookieHTTPOnly bool `koanf:"cookie_http_only"` CookiePersist bool `koanf:"cookie_persist"` CookieSecure bool `koanf:"cookie_secure"` CookieSameSite int `koanf:"cookie_same_site"` }
type SessionMiddleware ¶
type SessionMiddleware clevergo.MiddlewareFunc
func NewSessionMiddleware ¶
func NewSessionMiddleware(manager *scs.SessionManager) SessionMiddleware
type Validatable ¶
type Validatable interface {
Validate() error
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.