lib

package
v0.0.0-...-9ad592c Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module exports dependency

Functions

func SetConfigCasbinModelPath

func SetConfigCasbinModelPath(path string)

func SetConfigPath

func SetConfigPath(path string)

Types

type AuthConfig

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

type BinderWithValidation

type BinderWithValidation struct{}

Implement the bind method to verify the request's struct for parameter validation

func (BinderWithValidation) Bind

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

type Captcha

type Captcha struct {
	*base64Captcha.Captcha
}

func NewCaptcha

func NewCaptcha(redis Redis, logger Logger) Captcha

type CaptchaStore

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

func (CaptchaStore) Get

func (a CaptchaStore) Get(id string, clear bool) string

func (CaptchaStore) Set

func (a CaptchaStore) Set(id string, value string)

func (CaptchaStore) Verify

func (a CaptchaStore) Verify(id, answer string, clear bool) bool

type CasbinConfig

type CasbinConfig struct {
	Enable             bool     `mapstructure:"Enable"`
	Debug              bool     `mapstructure:"Debug"`
	Model              string   `mapstructure:"Model"`
	AutoLoad           bool     `mapstructure:"AutoLoad"`
	AutoLoadInternal   int      `mapstructure:"AutoLoadInternal"`
	IgnorePathPrefixes []string `mapstructure:"IgnorePathPrefixes"`
}

type Config

type Config struct {
	Name       string            `mapstructure:"Name"`
	Http       *HttpConfig       `mapstructure:"Http"`
	Log        *LogConfig        `mapstructure:"Log"`
	SuperAdmin *SuperAdminConfig `mapstructure:"SuperAdmin"`
	Auth       *AuthConfig       `mapstructure:"Auth"`
	Casbin     *CasbinConfig     `mapstructure:"Casbin"`
	Redis      *RedisConfig      `mapstructure:"Redis"`
	Database   *DatabaseConfig   `mapstructure:"Database"`
}

Configuration are the available config values

func NewConfig

func NewConfig() Config

type Database

type Database struct {
	ORM *gorm.DB
}

func NewDatabase

func NewDatabase(config Config, logger Logger) Database

NewDatabase creates a new database instance

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"`
	TablePrefix string `mapstructure:"TablePrefix"`
	Parameters  string `mapstructure:"Parameters"`

	MaxLifetime  int `mapstructure:"MaxLifetime"`
	MaxOpenConns int `mapstructure:"MaxOpenConns"`
	MaxIdleConns int `mapstructure:"MaxIdleConns"`
}

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
	RouterV1 *echo.Group

	Validate *validator.Validate
}

func NewHttpHandler

func NewHttpHandler(logger Logger, config Config) HttpHandler

NewHttpHandler creates a new request handler

type LogConfig

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

LogLevel : debug,info,warn,error,dpanic,panic,fatal

default info

Format : json, console

default json

Directory : Log storage path

default "./"

type Logger

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

Zap SugaredLogger by default DesugarZap performance-sensitive code

func NewLogger

func NewLogger(config Config) Logger

type Redis

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

func NewRedis

func NewRedis(config Config, logger Logger) Redis

NewRedis creates a new redis client instance

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 interface{}) error

func (Redis) GetClient

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

func (Redis) Set

func (a Redis) Set(key string, value interface{}, expiration time.Duration) error

type RedisConfig

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

func (*RedisConfig) Addr

func (a *RedisConfig) Addr() string

type SuperAdminConfig

type SuperAdminConfig struct {
	Username string `mapstructure:"Username"`
	Realname string `mapstructure:"Realname"`
	Password string `mapstructure:"Password"`
}

type Validator

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

HtppServer validation function

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