core

package
v0.0.0-...-08c03d6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func HashPassword

func HashPassword(password string) (string, error)

func InitLogger

func InitLogger(level LogLevel, logPath string, linkPath string) error

func LoadConfig

func LoadConfig(yamlFilePath string, cfg *Config) error

func Log

func Log(level LogLevel, msg string, ctx LogEvent)

func LogError

func LogError(level LogLevel, msg string, err error)

func ParseConnectionURL

func ParseConnectionURL(cfg *Config) (string, error)

func ParseMigrationConnectionURL

func ParseMigrationConnectionURL(cfg *Config) (string, error)

func UpperCaseFirst

func UpperCaseFirst(str string) string

Capitalises the first character of a string

Types

type AuthConfig

type AuthConfig struct {
	Realm          string `yaml:"realm"`
	SecretKey      string `yaml:"secret-key"`
	TokenTimeout   int32  `yaml:"token-timeout"`
	RefreshTimeout int32  `yaml:"refresh-timeout"`
}

type BusinessErr

type BusinessErr error

type CacheConfig

type CacheConfig struct {
	Enabled           bool   `yaml:"enabled"`
	Host              string `yaml:"host"`
	Password          string `yaml:"password"`
	DatabaseSelection int    `yaml:"database-selection"`
}

type Config

type Config struct {
	Database DatabaseConfig `yaml:"database"`
	Cache    CacheConfig    `yaml:"cache"`
	Auth     AuthConfig     `yaml:"auth"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Driver   string `yaml:"driver"`
	Username string `yaml:"username" envconfig:"DATABASE_USERNAME"`
	Password string `yaml:"password" envconfig:"DATABASE_PASSWORD"`
	Host     string `yaml:"host" envconfig:"DATABASE_HOST"`
	Port     string `yaml:"port" envconfig:"DATABASE_PORT"`
	DbName   string `yaml:"dbname" envconfig:"DATABASE_NAME"`
	SslMode  string `yaml:"ssl-mode"`
}

type DatabaseSortType

type DatabaseSortType string
const (
	Ascendent  DatabaseSortType = "asc"
	Descendent DatabaseSortType = "desc"
)

type ErrorBuilder

type ErrorBuilder func(string, string) *ErrorDetail

type ErrorDetail

type ErrorDetail struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

type ErrorMessage

type ErrorMessage struct {
	ErrorType string         `json:"errorType"`
	Detail    string         `json:"detail"`
	Status    int            `json:"status"`
	Errors    []*ErrorDetail `json:"errors,omitempty"`
}

func GetAuthError

func GetAuthError(message string, status int) *ErrorMessage

func GetDatabaseError

func GetDatabaseError(err error) *ErrorMessage

func GetErrorMessage

func GetErrorMessage(err error) *ErrorMessage

func GetSystemError

func GetSystemError(err error) *ErrorMessage

func GetValidationError

func GetValidationError(err error) *ErrorMessage

func NewErrorMessage

func NewErrorMessage(errType ErrorTypeCode, detail string, status int) *ErrorMessage

func (*ErrorMessage) AddErrorDetail

func (m *ErrorMessage) AddErrorDetail(err error, builder ErrorBuilder)

func (*ErrorMessage) Error

func (m *ErrorMessage) Error() string

type ErrorTypeCode

type ErrorTypeCode string

type LogEvent

type LogEvent map[string]interface{}

type SetupErr

type SetupErr error

type SystemErr

type SystemErr error

Jump to

Keyboard shortcuts

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