Documentation
¶
Index ¶
- func AuthMiddleware(c *fiber.Ctx) error
- func AuthMiddleware2(db *gorm.DB, JWTSecret string) fiber.Handler
- func DestroySession(c *fiber.Ctx) error
- func GetSession(c *fiber.Ctx) (bool, uint)
- func HasPermission(permissionCode string, userFunc func(c *fiber.Ctx) *models.User) fiber.Handler
- func InitAuthRouters()
- func InitModules(app *App)
- func InitPublicRouters()
- func IsDevelopment() bool
- func IsSecureMode() bool
- func LoadConfig() error
- func RegisterModule(module Module, priority int)
- func SessionSetup(dbDriver string, db *sql.DB, dsn, tableName string, expiry time.Duration)
- func SetSessionExpiration(c *fiber.Ctx, duration time.Duration) error
- func SkipAuthRoute(path string)
- func StoreSession(c *fiber.Ctx, userID uint) error
- func UpdateDatabaseConfig(newConfig DatabaseConfig)
- func UpdateFTPConfig(newConfig FTPConfig)
- func UpdateServerConfig(newConfig ServerConfig)
- type App
- type AppConfig
- type AuthConfig
- type BaseModule
- type Config
- type CorsConfig
- type DatabaseConfig
- type FTPConfig
- type FiberSession
- type JSONPathConfig
- type List
- type Map
- type Module
- type Response
- type SQLiteStorage
- type ServerConfig
- type StaticPathConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware2 ¶
AuthMiddleware 认证中间件
func HasPermission ¶
HasPermission 权限检查中间件
func LoadConfig ¶
func LoadConfig() error
func SessionSetup ¶
SessionSetup 初始化session存储
func SetSessionExpiration ¶
SetSessionExpiration 设置session过期时间
func UpdateDatabaseConfig ¶
func UpdateDatabaseConfig(newConfig DatabaseConfig)
func UpdateFTPConfig ¶
func UpdateFTPConfig(newConfig FTPConfig)
func UpdateServerConfig ¶
func UpdateServerConfig(newConfig ServerConfig)
Types ¶
type App ¶
type App struct {
FiberApp *fiber.App
DB *gorm.DB
DBs []*gorm.DB
Config *Config
RouterPublic fiber.Router
RouterPublicApi fiber.Router
RouterAdminApi fiber.Router
RouterAdmin fiber.Router
Bus *event.EventBus
}
func (*App) IsInitializedModule ¶
IsInitializedModule 如果模块已初始化,则跳过
type AuthConfig ¶
type BaseModule ¶
type BaseModule struct {
App *App
}
func (*BaseModule) AddAuthRouters ¶
func (m *BaseModule) AddAuthRouters() error
func (*BaseModule) AddPublicRouters ¶
func (m *BaseModule) AddPublicRouters() error
func (*BaseModule) Awake ¶
func (m *BaseModule) Awake(a *App) error
func (*BaseModule) Dispose ¶
func (m *BaseModule) Dispose() error
func (*BaseModule) Start ¶
func (m *BaseModule) Start() error
type Config ¶
type Config struct {
App AppConfig `toml:"app"`
Server ServerConfig `toml:"server"`
Database DatabaseConfig `toml:"database"`
JSONPaths JSONPathConfig `toml:"json_paths"`
FTP FTPConfig `toml:"ftp"`
Auth AuthConfig `toml:"auth"`
Cors CorsConfig `toml:"cors"`
}
type CorsConfig ¶
type CorsConfig struct {
Enabled bool `toml:"enabled"` // 是否启用跨域
AllowedOrigins []string `toml:"allowed_origins"` // 允许的源
AllowedMethods []string `toml:"allowed_methods"` // 允许的 HTTP 方法
AllowedHeaders []string `toml:"allowed_headers"` // 允许的请求头
AllowCredentials bool `toml:"allow_credentials"` // 是否允许携带认证信息
MaxAge int `toml:"max_age"` // 预检请求结果缓存时间(小时)
}
func GetCorsConfig ¶
func GetCorsConfig() CorsConfig
type DatabaseConfig ¶
type DatabaseConfig struct {
Driver string `toml:"driver"`
DSN string `toml:"dsn"`
MaxOpenConns int `toml:"max_open_conns"`
MaxIdleConns int `toml:"max_idle_conns"`
ConnMaxLifetime int64 `toml:"conn_max_lifetime"`
}
func GetDatabaseConfig ¶
func GetDatabaseConfig() DatabaseConfig
type FTPConfig ¶
type FTPConfig struct {
Host string `toml:"host"`
Port string `toml:"port"`
User string `toml:"user"`
Password string `toml:"password"`
APKPath string `toml:"apk_path"`
ZIPPath string `toml:"zip_path"`
LogDir string `toml:"log_dir"`
MaxLogSize int64 `toml:"max_log_size"`
}
func GetFTPConfig ¶
func GetFTPConfig() FTPConfig
type FiberSession ¶
type FiberSession struct {
K string `gorm:"column:k;primaryKey"` // key
V string `gorm:"column:v;not null"` // value
E int64 `gorm:"column:e;default:0"` // expiry
}
FiberSession Fiber默认的会话表结构
type JSONPathConfig ¶
type JSONPathConfig struct {
ServerList string `toml:"server_list"`
LastServer string `toml:"last_server"`
ServerInfo string `toml:"server_info"`
NoticeList string `toml:"notice_list"`
NoticeNum string `toml:"notice_num"`
}
func GetJSONPathConfig ¶
func GetJSONPathConfig() JSONPathConfig
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
SQLiteStorage 实现 fiber.Storage 接口
func NewSQLiteStorage ¶
func NewSQLiteStorage(dsn string) (*SQLiteStorage, error)
NewSQLiteStorage 创建新的SQLite存储
type ServerConfig ¶
type ServerConfig struct {
Host string `toml:"host"`
Port int `toml:"port"`
Output string `toml:"output"`
ScriptPath string `toml:"script_path"`
StaticPaths []StaticPathConfig `toml:"static_paths"`
UserDataPath string `toml:"user_data_path"`
CDNPath string `toml:"cdn_path"`
CDN2Path string `toml:"cdn2_path"`
}
func GetServerConfig ¶
func GetServerConfig() ServerConfig
type StaticPathConfig ¶
Click to show internal directories.
Click to hide internal directories.