Documentation
¶
Index ¶
- Variables
- type CORSConfig
- type Config
- type Database
- type DatabaseConfig
- type FxLogger
- type GinLogger
- type GormLogger
- func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
- func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
- func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})
- type JWTConfig
- type Logger
- type RequestHandler
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = fx.Options( fx.Provide(NewConfig), fx.Provide(NewDatabase), fx.Provide(GetLogger), fx.Provide(NewRequestHandler), )
Module exports lib module.
Functions ¶
This section is empty.
Types ¶
type CORSConfig ¶
type CORSConfig struct { Origins []string `mapstructure:"CORS_ORIGINS" default:"*"` Methods []string `mapstructure:"CORS_METHODS" default:"GET,POST,PUT,HEAD,OPTIONS,DELETE"` Headers []string `mapstructure:"CORS_HEADERS" default:"*"` }
CORSConfig represents CORS config.
type Config ¶
type Config struct { Env string `mapstructure:"ENV" default:"prod"` Server ServerConfig `mapstructure:",squash"` Database DatabaseConfig `mapstructure:",squash"` JWT JWTConfig `mapstructure:",squash"` CORS CORSConfig `mapstructure:",squash"` }
Config represents General config.
type DatabaseConfig ¶
type DatabaseConfig struct { Host string `mapstructure:"DB_HOST"` User string `mapstructure:"DB_USER"` Password string `mapstructure:"DB_PASSWORD"` Database string `mapstructure:"DB_NAME"` Port int `mapstructure:"DB_PORT"` }
DatabaseConfig represents Database config.
type GormLogger ¶
type GormLogger struct { *Logger gormlogger.Config }
GormLogger structure.
func (GormLogger) Error ¶
func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
Error prints error messages.
func (GormLogger) Info ¶
func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
Info prints info.
func (*GormLogger) LogMode ¶
func (l *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode set log mode.
type JWTConfig ¶
type JWTConfig struct { PrivateKeyLocation string `mapstructure:"JWT_PRIVATE_KEY_LOCATION"` PublicKeyLocation string `mapstructure:"JWT_PUBLIC_KEY_LOCATION"` Expiration time.Duration `mapstructure:"JWT_EXPIRATION" default:"48h"` }
JWTConfig represents JWT config.
type Logger ¶
type Logger struct {
*zap.SugaredLogger
}
Logger structure.
func (Logger) GetGinLogger ¶
GetGinLogger get the gin logger.
func (Logger) GetGormLogger ¶
func (l Logger) GetGormLogger() *GormLogger
GetGormLogger gets the gorm framework logger.
type RequestHandler ¶
RequestHandler function.
func NewRequestHandler ¶
func NewRequestHandler(config Config, logger Logger) RequestHandler
NewRequestHandler creates a new request handler.
type ServerConfig ¶
type ServerConfig struct { ListenAddr string `mapstructure:"SERVER_ADDR" default:"0.0.0.0"` Port int `mapstructure:"SERVER_PORT" default:"8080"` TrustedProxies []string `mapstructure:"TRUSTED_PROXIES"` }
ServerConfig represents Server config.
Click to show internal directories.
Click to hide internal directories.