config

package
v0.0.0-...-b8d2545 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 8 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"`
	Encryption   Encryption   `mapstructure:"encryption"`
	DbMySQL      DbMySQL      `mapstructure:"dbMysql"`
	Enforcer     Enforcer     `mapstructure:"enforcer"`
	GraphQL      GraphQL      `mapstructure:"graphQL"`
}

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) BuildEncryptionKeys

func (cfg *Config) BuildEncryptionKeys() error

BuildEncryptionKeys builds private key and public key RSA

func (*Config) Validate

func (cfg *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 Encryption

type Encryption struct {
	PrivateKey    string `mapstructure:"privateKey"`
	HashCost      int    `mapstructure:"hashCost"`
	PrivateKeyRSA *rsa.PrivateKey
	PublicKeyRSA  *rsa.PublicKey
}

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 GraphQL

type GraphQL struct {
	PublicFunctions []string `mapstructure:"publicFunctions"`
}

GraphQL defines the GraphQL configuration

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 {
	Secret       string                 `mapstructure:"jwtSecret"`
	Algorithm    jwa.SignatureAlgorithm `mapstructure:"jwtAlgorithm"`
	ExpiredInSec 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"`
}

Jump to

Keyboard shortcuts

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