Documentation ¶
Index ¶
Constants ¶
View Source
const ( CacheNSForUser = "user" CacheNSForRole = "role" )
View Source
const ( ErrInvalidTokenID = "com.invalid.token" ErrInvalidCaptchaID = "com.invalid.captcha" ErrInvalidUsernameOrPassword = "com.invalid.username-or-password" )
View Source
const (
CacheKeyForSyncToCasbin = "sync:casbin"
)
Variables ¶
View Source
var (
C = new(Config)
)
Functions ¶
Types ¶
type Config ¶
type Config struct { Logger logging.LoggerConfig General General Storage Storage Middleware Middleware Util Util Dictionary Dictionary }
func (*Config) FormatTableName ¶
type Dictionary ¶
type Dictionary struct {
UserCacheExp int `default:"4"` // hours
}
type General ¶
type General struct { AppName string `default:"ginadmin"` Version string `default:"v10.0.2"` Debug bool PprofAddr string DisableSwagger bool DisablePrintConfig bool DefaultLoginPwd string `default:"6351623c8cef86fefabfa7da046fc619"` // MD5(abc-123) WorkDir string // From command arguments MenuFile string // From schema.Menus (JSON/YAML) DenyDeleteMenu bool HTTP struct { Addr string `default:":8040"` ShutdownTimeout int `default:"10"` // seconds ReadTimeout int `default:"60"` // seconds WriteTimeout int `default:"60"` // seconds IdleTimeout int `default:"10"` // seconds CertFile string KeyFile string } Root struct { ID string `default:"root"` Username string `default:"admin"` Password string Name string `default:"Admin"` } }
type Middleware ¶
type Middleware struct { Recovery struct { Skip int `default:"3"` // skip the first n stack frames } CORS struct { Enable bool AllowAllOrigins bool AllowOrigins []string AllowMethods []string AllowHeaders []string AllowCredentials bool ExposeHeaders []string MaxAge int AllowWildcard bool AllowBrowserExtensions bool AllowWebSockets bool AllowFiles bool } Trace struct { SkippedPathPrefixes []string RequestHeaderKey string `default:"X-Request-Id"` ResponseTraceKey string `default:"X-Trace-Id"` } Logger struct { SkippedPathPrefixes []string MaxOutputRequestBodyLen int `default:"4096"` MaxOutputResponseBodyLen int `default:"1024"` } CopyBody struct { SkippedPathPrefixes []string MaxContentLen int64 `default:"33554432"` // max content length (default 32MB) } Auth struct { Disable bool SkippedPathPrefixes []string SigningMethod string `default:"HS512"` // HS256/HS384/HS512 SigningKey string `default:"XnEsT0S@"` // secret key OldSigningKey string // old secret key (for migration) Expired int `default:"86400"` // seconds Store struct { Type string `default:"memory"` // memory/badger/redis Delimiter string `default:":"` // delimiter for key Memory struct { CleanupInterval int `default:"60"` // seconds } Badger struct { Path string `default:"data/auth"` } Redis struct { Addr string Username string Password string DB int } } } RateLimiter struct { Enable bool SkippedPathPrefixes []string Period int // seconds MaxRequestsPerIP int MaxRequestsPerUser int Store struct { Type string // memory/redis Memory struct { Expiration int `default:"3600"` // seconds CleanupInterval int `default:"60"` // seconds } Redis struct { Addr string Username string Password string DB int } } } Casbin struct { Disable bool SkippedPathPrefixes []string LoadThread int `default:"2"` AutoLoadInterval int `default:"3"` // seconds ModelFile string `default:"rbac_model.conf"` GenPolicyFile string `default:"gen_rbac_policy.csv"` } Static struct { Dir string // Static files directory (From command arguments) } }
type Storage ¶
type Storage struct { Cache struct { Type string `default:"memory"` // memory/badger/redis Delimiter string `default:":"` // delimiter for key Memory struct { CleanupInterval int `default:"60"` // seconds } Badger struct { Path string `default:"data/cache"` } Redis struct { Addr string Username string Password string DB int } } DB struct { Debug bool Type string `default:"sqlite3"` // sqlite3/mysql/postgres DSN string `default:"data/ginadmin.db"` // database source name MaxLifetime int `default:"86400"` // seconds MaxIdleTime int `default:"3600"` // seconds MaxOpenConns int `default:"100"` // connections MaxIdleConns int `default:"50"` // connections TablePrefix string `default:""` AutoMigrate bool Resolver []struct { DBType string // sqlite3/mysql/postgres Sources []string // DSN Replicas []string // DSN Tables []string } } }
type Util ¶
type Util struct { Captcha struct { Length int `default:"4"` Width int `default:"400"` Height int `default:"160"` CacheType string `default:"memory"` // memory/redis Redis struct { Addr string Username string Password string DB int KeyPrefix string `default:"captcha:"` } } Prometheus struct { Enable bool Port int `default:"9100"` BasicUsername string `default:"admin"` BasicPassword string `default:"admin"` LogApis []string LogMethods []string DefaultCollect bool } }
Click to show internal directories.
Click to hide internal directories.