lib

package
v0.0.0-...-4468c4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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.

func NewConfig

func NewConfig() (conf Config)

NewConfig creates a new Config.

type Database

type Database struct {
	*gorm.DB
}

Database data structure.

func NewDatabase

func NewDatabase(config Config, logger Logger) Database

NewDatabase creates a new Database.

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 FxLogger

type FxLogger struct {
	*Logger
}

FxLogger structure.

func (FxLogger) LogEvent

func (l FxLogger) LogEvent(event fxevent.Event)

LogEvent logs the given event to the provided Zap logger.

type GinLogger

type GinLogger struct {
	*Logger
}

GinLogger structure.

func (GinLogger) Write

func (l GinLogger) Write(data []byte) (n int, err error)

Write interface implementation for gin-framework.

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

LogMode set log mode.

func (GormLogger) Trace

func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace prints trace messages.

func (GormLogger) Warn

func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})

Warn prints warn messages.

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 GetLogger

func GetLogger(config Config) Logger

GetLogger get the logger.

func (Logger) GetFxLogger

func (l Logger) GetFxLogger() FxLogger

GetFxLogger get the fx logger.

func (Logger) GetGinLogger

func (l Logger) GetGinLogger() GinLogger

GetGinLogger get the gin logger.

func (Logger) GetGormLogger

func (l Logger) GetGormLogger() *GormLogger

GetGormLogger gets the gorm framework logger.

type RequestHandler

type RequestHandler struct {
	Gin *gin.Engine
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL