lib

package
v0.0.0-...-bbcf6c5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 28 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 AuthConfig

type AuthConfig struct {
	Enable             string   `mapstructure:"Enable"`
	TokenExpired       int      `mapstructure:"TokenExpired"`
	IgnorePathPrefixes []string `mapstructure:"IgnorePathPrefixes"`
}

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"`
	Secret   string          `mapstructure:"Secret"`
	Http     *HttpConfig     `mapstructure:"Http"`
	Log      *LogConfig      `mapstructure:"Log"`
	Database *DatabaseConfig `mapstructure:"Database"`
	Mail     *MailConfig     `mapstructure:"Mail"`
	Cors     *CorsConfig     `mapstructure:"Cors"`
	Swagger  *SwaggerConfig  `mapstructure:"Swagger"`
	Auth     *AuthConfig     `mapstructure:"Auth"`
}

func NewConfig

func NewConfig() Config

type CorsConfig

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

type Database

type Database struct {
	ORM *gorm.DB
}

func NewDatabase

func NewDatabase(config Config, logger Logger) 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"`
	SslMode      string `mapstructure:"SslMode"`
	TimeZone     string `mapstructure:"TimeZone"`
	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
	Validate *validator.Validate
}

func NewHttpHandler

func NewHttpHandler(logger Logger) HttpHandler

type LogConfig

type LogConfig struct {
	Level       string `mapstructure:"Level"`
	Format      string `mapstructure:"Format"`
	Directory   string `mapstructure:"Directory"`
	Development string `mapstructure:"Development"`
}

type Logger

type Logger struct {
	Zap        *zap.SugaredLogger
	DesugarZap *zap.Logger
}

func NewLogger

func NewLogger(config Config) Logger

type Mail

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

func NewMail

func NewMail(config Config, logger Logger) 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 SwaggerConfig

type SwaggerConfig struct {
	Title       string `mapstructrue:"Title"`
	Description string `mapstructure:"Description"`
	Version     string `mapstructure:"Version"`
	PathUrl     string `mapstructure:"PathUrl"`
	DocUrl      string `mapstructure:"DocUrl"`
}

type Validator

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

func (*Validator) Validate

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

Jump to

Keyboard shortcuts

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