Documentation
¶
Index ¶
- Variables
- func GetMessage(code int) string
- func GlobalErrorMiddleware() gin.HandlerFunc
- func LoadConfig[T any](yamlFile string) (*T, error)
- func NewHttpServer(app *Application, logger *AppLogger) *http.Server
- func SaveConfig[T any](cfg *T, yamlFile string) error
- func SetErrorInfo(ei map[int]string)
- type AppLogger
- func (logger *AppLogger) Debug(msg string, args ...any)
- func (logger *AppLogger) DebugContext(ctx context.Context, msg string, args ...any)
- func (logger *AppLogger) Enabled(ctx context.Context, level slog.Level) bool
- func (logger *AppLogger) Error(msg string, args ...any)
- func (logger *AppLogger) ErrorContext(ctx context.Context, msg string, args ...any)
- func (logger *AppLogger) Handler() slog.Handler
- func (logger *AppLogger) Info(msg string, args ...any)
- func (logger *AppLogger) InfoContext(ctx context.Context, msg string, args ...any)
- func (logger *AppLogger) Log(ctx context.Context, level slog.Level, msg string, args ...any)
- func (logger *AppLogger) LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
- func (logger *AppLogger) Warn(msg string, args ...any)
- func (logger *AppLogger) WarnContext(ctx context.Context, msg string, args ...any)
- type Application
- type ApplicationConfig
- type DBParams
- type DBToolKit
- type LoggerParams
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = fx.Module("bootstrap", fx.Provide( NewLogger, NewDB, NewApplication, ), )
Module exports dependency
Functions ¶
func GetMessage ¶
func GlobalErrorMiddleware ¶
func GlobalErrorMiddleware() gin.HandlerFunc
func NewHttpServer ¶
func NewHttpServer(app *Application, logger *AppLogger) *http.Server
func SaveConfig ¶
SaveConfig 将配置信息保存到指定的YAML文件中
func SetErrorInfo ¶
Types ¶
type AppLogger ¶
type AppLogger struct {
// fx.In
RawLogger *slog.Logger
Params LoggerParams
}
func (*AppLogger) DebugContext ¶
func (*AppLogger) ErrorContext ¶
func (*AppLogger) InfoContext ¶
type Application ¶
type Application struct {
// Configuration
Config *ApplicationConfig
// contains filtered or unexported fields
}
func NewApplication ¶
func NewApplication(logger *AppLogger, cfg *ApplicationConfig, lc fx.Lifecycle) *Application
func (*Application) RunServer ¶
func (app *Application) RunServer(logger *AppLogger) error
type ApplicationConfig ¶
type ApplicationConfig struct {
// Configuration of server trusted proxies
TrustedProxies string
// Configuration of server address
ServerAddr string
// verbose flag
Verbose bool
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type DBParams ¶
type DBParams struct {
Type string
Host string
Port int
Database string
User string
Password string
}
func NewDBParams ¶
func (DBParams) GetConnectionString ¶
type LoggerParams ¶
Click to show internal directories.
Click to hide internal directories.