lib

package
v0.0.0-...-c48e8af Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 18 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 Config

type Config struct {
	Name     string          `mapstructure:"Name"`
	Secret   string          `mapstructure:"Secret"`
	Http     *HttpConfig     `mapstructure:"Http"`
	Database *DatabaseConfig `mapstructure:"Database"`
	Auth     *AuthConfig     `mapstructure:"Auth"`
	Cors     *CorsConfig     `mapstructure:"Cors"`
	Swagger  *SwaggerConfig  `mapstructure:"Swagger"`
	Mail     *MailConfig     `mapstructure:"Mail"`
}

func NewConfig

func NewConfig() Config

type CorsConfig

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

type Database

type Database struct {
	ORM *gorm.DB
}

func NewDatabase

func NewDatabase(config Config) Database

type DatabaseConfig

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

func (DatabaseConfig) DSN

func (d 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 (h HttpConfig) ListenAddr() string

type HttpHandler

type HttpHandler struct {
	Engine *gin.Engine
}

func NewHttpHandler

func NewHttpHandler() HttpHandler

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 SwaggerConfig

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

Jump to

Keyboard shortcuts

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