Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
C = new(Config)
)
Functions ¶
Types ¶
type Config ¶
type Config struct { General General Storage Storage Logger Logger Middleware Middleware ExtConfig any }
type General ¶
type General struct { AppName string `default:"mog"` DebugMode bool ContextPath string `default:""` PprofAddr string EnableSwagger bool EnablePrintConfig bool HTTP struct { Addr string `default:":8000"` ShutdownTimeout int `default:"10"` ReadTimeout int `default:"60"` // seconds WriteTimeout int `default:"60"` // seconds IdleTimeout int `default:"10"` // seconds CertFile string KeyFile string } }
type Middleware ¶
type Middleware struct { Recovery struct { Skip int `default:"3"` } 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) } 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 } } } Auth struct { Disable bool SkippedPathPrefixes []string SigningMethod string `default:"HS512"` // HS256/HS384/HS512 SigningKey string `default:"cptbtptpbcptdtptp"` Expired int `default:"86400"` Store struct { Type string `default:"badger"` // badger/redis Delimiter string `default:":"` // delimiter for key Badger struct { Path string `default:"data/auth"` } Redis struct { Addr string Username string Password string DB int } } } }
type Storage ¶
type Storage struct { Cache struct { Type string `default:"memory"` // memory/badger/redis Delimiter string `default:":"` Memory struct { CleanupInterval int `default:"60"` } Badger struct { Path string } Redis struct { Addr string Username string Password string DB int } } DataBase struct { Enable bool `default:"true"` Debug bool Type string `default:"sqlite3"` // sqlite3/mysql/postgres DSN string `default:"data/sqlite/106hz.db"` MaxLifetime int `default:"86400"` MaxIdleTime int `default:"3600"` MaxOpenConns int `default:"100"` MaxIdleConns int `default:"50"` TablePrefix string `default:""` AutoMigrate bool Resolver []struct { DBType string // sqlite3/mysql/postgres Sources []string // DSN Replicas []string // DSN Tables []string } } }
Click to show internal directories.
Click to hide internal directories.