Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = App{ Server: Server{ Address: "127.0.0.1:8080", BasePath: "/api", ReadTimeout: duration.Minute, WriteTimeout: duration.Minute, IdleTimeout: 5 * duration.Minute, MultipartMax: 50 << 20, Pprof: false, Swagger: true, }, Log: Log{ Filename: "/etc/ginx-internal/internal.log", Prompt: "[ginx-internal]", Level: slog.LevelInfo, Format: logx.TextFormat, Source: false, Color: false, }, DB: DB{ Driver: "unset", Address: "127.0.0.1:3306", User: "user", Password: "password", Database: "database", Params: "", MaxIdleConnections: 10, MaxOpenConnections: 100, MaxLifeTime: duration.Hour, MaxIdleTime: 10 * duration.Minute, }, Redis: Redis{ Address: "127.0.0.1:6379", Password: "password", WriteTimeout: duration.Minute, ReadTimeout: duration.Minute, }, Email: Email{ Host: "", Port: 0, Username: "", Password: "", MQ: EmailMq{ Topic: "email", BatchSize: 20, Group: "email-group", Consumers: []string{"consumerA"}, }, Code: VerifyCode{ TTL: 5 * duration.Minute, RetryTTL: duration.Minute, }, }, Jwt: Jwt{ Issuer: "lobby", Access: AccessToken{ Expire: 4 * duration.Hour, Delay: 10 * duration.Minute, Key: "01J6EA2G4FSF9ABC218VFJ2B3C", }, Refresh: RefreshToken{ Expire: 144 * duration.Hour, Key: "01J6EA3FKDDHTT9Q8Z5YKWHVCE", }, }, }
DefaultConfig is the default configuration for application
Functions ¶
Types ¶
type AccessToken ¶
type App ¶
type App struct {
Server Server `toml:"server" comment:"http server configuration"`
Log Log `toml:"log" comment:"server log configuration"`
DB DB `toml:"db" comment:"database connection configuration"`
Redis Redis `toml:"redis" comment:"redis connection configuration"`
Email Email `toml:"email" comment:"email smtp client configuration"`
Jwt Jwt `toml:"jwt" comment:"jwt secret configuration"`
Meta MetaInfo `toml:"-"`
}
App is configuration for the whole application
type DB ¶
type DB struct {
Driver string `toml:"driver" comment:"sqlite | mysql | postgresql"`
Address string `toml:"address" comment:"db internal host"`
User string `toml:"user" comment:"db username"`
Password string `toml:"password" comment:"db password"`
Database string `toml:"database" comment:"database name"`
Params string `toml:"param" comment:"connection params"`
MaxIdleConnections int `toml:"maxIdleConnections" comment:"max idle connections limit"`
MaxOpenConnections int `toml:"maxOpenConnections" comment:"max opening connections limit"`
MaxLifeTime duration.Duration `toml:"maxLifeTime" comment:"max connection lifetime"`
MaxIdleTime duration.Duration `toml:"maxIdleTime" comment:"max connection idle time"`
}
DB is configuration for database
type Email ¶
type Email struct {
Host string `toml:"host" comment:"smtp internal host"`
SSL bool `toml:"ssl" comment:"use ssl port"`
Port int `toml:"port" comment:"smtp internal port"`
Username string `toml:"username" comment:"smtp user name"`
Password string `toml:"password" comment:"password to authenticate"`
Template string `toml:"template" comment:"custom email template dir"`
MQ EmailMq `toml:"-"`
Code VerifyCode `toml:"code" comment:"email verification code configuration"`
}
type Jwt ¶
type Jwt struct {
Issuer string `toml:"issuer" comment:"jwt issuer"`
Access AccessToken `toml:"access" comment:"access token configuration"`
Refresh RefreshToken `toml:"refresh" comment:"refresh token configuration"`
}
Jwt is configuration for jwt signing
type Log ¶
type Log struct {
Filename string `toml:"filename" comment:"log output file"`
Prompt string `toml:"-"`
Level slog.Level `toml:"level" comment:"support levels: DEBUG | INFO | WARN | ERROR"`
Format string `toml:"format" comment:"TEXT or JSON"`
Source bool `toml:"source" comment:"whether to show source file in logs"`
Color bool `toml:"color" comment:"enable color log"`
}
Log is configuration for logging
type Redis ¶
type Redis struct {
Address string `toml:"address" comment:"host address"`
Password string `toml:"password" comment:"redis auth"`
WriteTimeout duration.Duration `toml:"writeTimeout" comment:"Timeout for socket writes."`
ReadTimeout duration.Duration `toml:"readTimeout" comment:"Timeout for socket reads."`
}
Redis is configuration for redis internal
type RefreshToken ¶
type Server ¶
type Server struct {
Address string `toml:"address" comment:"server bind address"`
BasePath string `toml:"basepath" comment:"base path for api"`
ReadTimeout duration.Duration `toml:"readTimeout" comment:"the maximum duration for reading the entire request"`
WriteTimeout duration.Duration `toml:"writeTimeout" comment:"the maximum duration before timing out writes of the response"`
IdleTimeout duration.Duration `toml:"idleTimeout" comment:"the maximum amount of time to wait for the next request when keep-alives are enabled"`
MultipartMax int64 `toml:"multipartMax" comment:"value of 'maxMemory' param that is given to http.Request's ParseMultipartForm"`
Pprof bool `toml:"pprof" comment:"enabled pprof program profiling"`
Swagger bool `toml:"swagger" comment:"enable swagger documentation"`
TLS TLS `toml:"tls" comment:"tls certificate"`
}
Server is configuration for the http server
Click to show internal directories.
Click to hide internal directories.