config

package
v0.0.0-...-f356f3c Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 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 Config

type Config struct {
	General      General      `mapstructure:"general"`
	Log          Log          `mapstructure:"log"`
	LogPublisher LogPublisher `mapstructure:"logPublisher"`
	Http         Http         `mapstructure:"http"`
	Cors         Cors         `mapstructure:"cors"`
	JwtAuth      JwtAuth      `mapstructure:"jwtAuth"`
	DbMySQL      DbMySQL      `mapstructure:"dbMysql"`
	Enforcer     Enforcer     `mapstructure:"enforcer"`
}

func Get

func Get() (*Config, error)

Get gets config object

func Load

func Load() (*Config, error)

Load loads config from the config.yaml

func (*Config) Validate

func (*Config) Validate() error

Validate validates any miss configurations or missing configs

type Cors

type Cors struct {
	AllowedOrigins   []string `mapstructure:"allowedOrigins"`
	AllowedMethods   []string `mapstructure:"allowedMethods"`
	AllowedHeaders   []string `mapstructure:"allowedHeaders"`
	ExposedHeaders   []string `mapstructure:"exposedHeaders"`
	AllowCredentials bool     `mapstructure:"allowCredentials"`
	MaxAge           int      `mapstructure:"maxAge"`
	Debug            bool     `mapstructure:"debug"`
}

Cors defines cors-related configurations

type DbMySQL

type DbMySQL struct {
	Host   string `mapstructure:"host"`
	Port   string `mapstructure:"port"`
	User   string `mapstructure:"user"`
	Pass   string `mapstructure:"pass"`
	DbName string `mapstructure:"dbName"`
}

DbMySQL defines the database connection for MySQL database

type Enforcer

type Enforcer struct {
	ModelFile string `mapstructure:"modelFile"`
	TableName string `mapstructure:"tableName"`
}

Enforcer defines the enforcer configuration

type General

type General struct {
	BuildMode string `mapstructure:"buildMode"`
}

type Http

type Http struct {
	Address        string        `mapstructure:"address"`
	Port           int           `mapstructure:"port"`
	RequestTimeout time.Duration `mapstructure:"requestTimeout"`
	ReadTimeout    time.Duration `mapstructure:"readTimeout"`  // The maximum time to wait while writing data to the server
	WriteTimeout   time.Duration `mapstructure:"writeTimeout"` // The maximum time to wait while reading data from the server
	HttpClientTLS  bool          `mapstructure:"httpClientTLS"`
	LogHttpRequest bool          `mapstructure:"logHttpRequest"`
}

type JwtAuth

type JwtAuth struct {
	JWTSecret       string                 `mapstructure:"jwtSecret"`
	JWTAlgorithm    jwa.SignatureAlgorithm `mapstructure:"jwtAlgorithm"`
	JWTExpiredInSec int                    `mapstructure:"jwtExpiredInSec"`
}

JwtAuth defines JWT authentication related

type Log

type Log struct {
	Level  string `mapstructure:"level"`
	Format string `mapstructure:"format"`
}

type LogPublisher

type LogPublisher struct {
	Notice bool `mapstructure:"notice"`
	Error  bool `mapstructure:"error"`
	Info   bool `mapstructure:"info"`
	Warn   bool `mapstructure:"warn"`
	Debug  bool `mapstructure:"debug"`
}

type Reader

type Reader interface {
	Get(key string) string
}

type ViperConfigReader

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

Jump to

Keyboard shortcuts

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