lib

package
v0.0.0-...-042b7a9 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetVersion

func GetVersion(filename string) (int64, error)

func SetConfigPath

func SetConfigPath(path string)

Types

type BinderWithValidation

type BinderWithValidation struct{}

func (BinderWithValidation) Bind

func (BinderWithValidation) Bind(i interface{}, ctx echo.Context) error

type Config

type Config struct {
	Name      string `mapstructure:"Name"`
	SecretKey string `mapstructure:"SecretKey"`

	Http     *HttpConfig     `mapstructure:"Http"`
	Database *DatabaseConfig `mapstructure:"Database"`
	JWT      *JWTConfig      `mapstructure:"Jwt"`
	Mail     *MailConfig     `mapstructure:"Mail"`
	Swagger  *SwaggerConfig  `mapstructure:"Swagger"`
	Redis    *RedisConfig    `mapstructure:"Redis"`
	Cors     *CorsConfig     `mapstructure:"Cors"`
}

func NewConfig

func NewConfig() Config

type CorsConfig

type CorsConfig struct {
	AllowOrigins []string `mapstructure:"AllowOrigins"`
	AllowMethods []string `mapstructure:"AllowMethods"`
}

type Database

type Database struct {
	ORM *gorm.DB
}

func NewDatabase

func NewDatabase(config Config) Database

type DatabaseConfig

type DatabaseConfig struct {
	Engine       string `mapstructure:"Engine"`
	Name         string `mapstructure:"Name"`
	Host         string `mapstructure:"Host"`
	Port         int    `mapstructure:"Port"`
	Username     string `mapstructure:"Username"`
	Password     string `mapstructure:"Password"`
	Parameters   string `mapstructure:"Parameters"`
	MigrationDir string `mapstructure:"MigrationDir"`
}

func (*DatabaseConfig) DSN

func (a *DatabaseConfig) DSN() string

type HttpConfig

type HttpConfig struct {
	Host string `mapstructure:"Host" validate:"ipv4"`
	Port int    `mapstructure:"Port" validate:"gte=1,lte=65535"`
}

func (*HttpConfig) ListenAddr

func (a *HttpConfig) ListenAddr() string

type HttpHandler

type HttpHandler struct {
	Engine *echo.Echo
}

func NewHttpHandler

func NewHttpHandler() HttpHandler

type IRedis

type IRedis interface {
	Set(key string, value any, expiration time.Duration) error
	Get(key string, value any) error
	Delete(keys ...string) (bool, error)
	Check(keys ...string) (bool, error)
}

type JWT

type JWT struct {
	Claims jwt.Claims
	Secret string
}

func NewJWT

func NewJWT(config Config) JWT

func (JWT) GenerateToken

func (l JWT) GenerateToken(id int64) (string, error)

func (JWT) GetSubjectFromToken

func (l JWT) GetSubjectFromToken(token string) (int64, error)

type JWTConfig

type JWTConfig struct {
	TokenLifeTime int `mapstructure:"TokenLifeTime"`
}

type Mail

type Mail struct {
	// contains filtered or unexported fields
}

func NewMail

func NewMail(config Config) Mail

func (Mail) SendMail

func (l Mail) SendMail(subject string, body string, receivers []string, sender string)

func (Mail) SendMailAsLog

func (l Mail) SendMailAsLog(subject string, body string, receivers []string, sender string)

func (Mail) SendMailWithTemplate

func (l Mail) SendMailWithTemplate(mailTemplate MailTemplate)

type MailConfig

type MailConfig struct {
	Enable    bool   `mapstructure:"Enable"`
	Host      string `mapstructure:"Host"`
	Port      int    `mapstructure:"Port"`
	User      string `mapstructure:"User"`
	Password  string `mapstructure:"Password"`
	UseTLS    bool   `mapstructure:"UseTLS"`
	FromEmail string `mapstructure:"FromEmail"`
}

type MailTemplate

type MailTemplate struct {
	Subject   string
	Body      string
	Sender    string
	Receivers []string
	Context   map[string]interface{}
}

func (MailTemplate) GetBody

func (m MailTemplate) GetBody() string

func (MailTemplate) GetSubject

func (m MailTemplate) GetSubject() string

func (MailTemplate) ReadTemplate

func (m MailTemplate) ReadTemplate(templateName string) (string, error)

type Migration

type Migration struct {
	// contains filtered or unexported fields
}

func NewMigration

func NewMigration(config Config) Migration

func (Migration) Create

func (l Migration) Create(filename string) error

func (Migration) Down

func (l Migration) Down(filename string, db *sql.DB) error

func (Migration) Migrate

func (l Migration) Migrate(command string, filename string, database Database) error

func (Migration) Redo

func (l Migration) Redo(db *sql.DB) error

func (Migration) Up

func (l Migration) Up(filename string, db *sql.DB) error

type Redis

type Redis struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(config Config) Redis

func (Redis) Check

func (a Redis) Check(keys ...string) (bool, error)

func (Redis) Close

func (a Redis) Close() error

func (Redis) Delete

func (a Redis) Delete(keys ...string) (bool, error)

func (Redis) Get

func (a Redis) Get(key string, value any) error

func (Redis) GetClient

func (a Redis) GetClient() *redis.Client

func (Redis) Set

func (a Redis) Set(key string, value any, expiration time.Duration) error

type RedisConfig

type RedisConfig struct {
	Host      string `mapstructure:"Host"`
	Port      int    `mapstructure:"Port"`
	KeyPrefix string `mapstructure:"KeyPrefix"`
}

func (*RedisConfig) Addr

func (a *RedisConfig) Addr() string

type SwaggerConfig

type SwaggerConfig struct {
	Title       string `mapstructure:"Title"`
	Description string `maptsructure:"Description"`
	Version     string `mapstructure:"Version"`
}

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func (*Validator) Validate

func (a *Validator) Validate(i interface{}) error

Jump to

Keyboard shortcuts

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