config

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID      string
	Name    string
	Version string
	Server  *struct {
		Http *HttpService
		Grpc *GrpcService
	}
	Log            *Logger
	Pool           *Pool
	Email          *Email
	JWT            *JWT
	Authentication *Authentication
	Tracing        *Tracing
	Database       map[string]Database
	Redis          map[string]Redis
	Loader         map[string]string
	Captcha        map[string]Captcha
	RateLimit      bool
}

func Load

func Load(config config.Config) (*App, error)

type Authentication

type Authentication struct {
	DB        string
	Prefix    string
	Redis     string
	RoleKey   string
	Whitelist map[string]bool
	SkipRole  []string
}

type Captcha

type Captcha struct {
	Type     string
	Length   int
	Expire   time.Duration
	Redis    string
	Height   int
	Width    int
	Skew     float64
	DotCount int
	Template string
}

type Cors added in v1.0.18

type Cors struct {
	AllowCredentials    bool
	AllowOrigins        []string
	AllowMethods        []string
	AllowHeaders        []string
	ExposeHeaders       []string
	MaxAge              time.Duration
	AllowPrivateNetwork bool
}

type DBTransformError added in v1.0.17

type DBTransformError struct {
	Format *struct {
		Duplicated *string
		AddForeign *string
		DelForeign *string
	}
}

type Database

type Database struct {
	Enable         bool
	TablePrefix    string
	Drive          string
	Dsn            string
	MaxLifetime    time.Duration
	MaxOpenConn    int
	MaxIdleConn    int
	LogLevel       int
	PrepareStmt    bool
	DryRun         bool
	TransformError *DBTransformError
	SlowThreshold  time.Duration
}

type Email

type Email struct {
	User     string
	Name     string
	Password string
	Host     string
	Port     int
	Template map[string]EmailTemplate
}

type EmailTemplate

type EmailTemplate struct {
	Subject string
	Path    string
	Enable  *bool
	From    string
	Type    string
}

type GrpcService added in v1.0.18

type GrpcService struct {
	Network     string
	Addr        string
	MaxRecvSize int
	Timeout     time.Duration
}

type HttpService added in v1.0.18

type HttpService struct {
	Network        string
	Addr           string
	Timeout        time.Duration
	FormatResponse bool
	Cors           *Cors
	Marshal        *Marshal
}

type JWT

type JWT struct {
	Redis     string
	Header    string
	Secret    string
	Expire    time.Duration
	Renewal   time.Duration
	Whitelist map[string]bool
}

type Logger

type Logger struct {
	Level  int8
	Output []string
	File   *struct {
		Name      string
		MaxSize   int
		MaxBackup int
		MaxAge    int
		Compress  bool
		LocalTime bool
	}
}

type Marshal added in v1.0.22

type Marshal struct {
	ForceUseJson    bool
	EmitUnpopulated bool
	UseProtoNames   bool
}

type Pool

type Pool struct {
	Size             int
	ExpiryDuration   time.Duration
	PreAlloc         bool
	MaxBlockingTasks int
	Nonblocking      bool
}

type Redis

type Redis struct {
	Enable   bool
	Name     string
	Host     string
	Username string
	Password string
}

type Tracing added in v1.0.3

type Tracing struct {
	HttpEndpoint string
	SampleRatio  *float32
	Timeout      time.Duration
	Insecure     *bool
}

Jump to

Keyboard shortcuts

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