config

package
v0.0.0-...-40b14aa Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AvailableStatusOnline  = "online"
	AvailableStatusOffline = "offline"
)
View Source
var (
	CF = &Configs{}
)

Functions

func InitConfig

func InitConfig() error

InitConfig init config

Types

type AvailableConfig

type AvailableConfig struct {
	Status string `json:"status"`
}

type Configs

type Configs struct {
	Info struct {
		Name          string `mapstructure:"NAME"`
		Description   string `mapstructure:"DESCRIPTION"`
		Pubkey        string `mapstructure:"PUBKEY"`
		Contact       string `mapstructure:"CONTACT"`
		SupportedNIPs []int  `mapstructure:"SUPPORTED_NIPS" json:"supported_nips"`
		Software      string `mapstructure:"SOFTWARE"`
		Version       string `mapstructure:"VERSION"`
		Icon          string `mapstructure:"ICON"`
		/*Limitation    struct {
			MaxMessageLength int  `mapstructure:"MAX_MESSAGE_LENGTH"`
			MaxSubscriptions int  `mapstructure:"MAX_SUBSCRIPTIONS"`
			MaxFilters       int  `mapstructure:"MAX_FILTERS"`
			MaxLimit         int  `mapstructure:"MAX_LIMIT"`
			MaxSubidLength   int  `mapstructure:"MAX_SUBID_LENGTH"`
			MaxEventTags     int  `mapstructure:"MAX_EVENT_TAGS"`
			MaxContentLength int  `mapstructure:"MAX_CONTENT_LENGTH"`
			MinPowDifficulty int  `mapstructure:"MIN_POW_DIFFICULTY"`
			AuthRequired     bool `mapstructure:"AUTH_REQUIRED"`
			PaymentRequired  bool `mapstructure:"PAYMENT_REQUIRED"`
			RestrictedWrites bool `mapstructure:"RESTRICTED_WRITES"`
		} `mapstructure:"LIMITATION"`*/
		Limitation *infoLimitation `mapstructure:"LIMITATION"`
	} `mapstructure:"INFO"`

	App struct {
		AvailableStatus string      // สถานะปิด/เปิดระบบ [on/off]
		Port            int         `mapstructure:"PORT"`
		Environment     Environment `mapstructure:"ENVIRONMENT"`
	} `mapstructure:"APP"`

	Database struct {
		RelaySQL DatabaseConfig `mapstructure:"RELAY_SQL"`
	} `mapstructure:"DATABASE"`

	HTMLTemplate struct {
		SystemMaintenance string `mapstructure:"SYSTEM_MAINTENANCE"`
	} `mapstructure:"HTML_TEMPLATE"`
}

func (*Configs) ReadConfigAvailableDescription

func (cf *Configs) ReadConfigAvailableDescription() (string, error)

ReadConfigAvailableDescription read config available description อ่าน config html ใช้แสดงเมื่อปิดระบบ

func (*Configs) SetConfigAvailableDescription

func (cf *Configs) SetConfigAvailableDescription(body string) error

SetConfigAvailableDescription set config available description สร้าง config html ใช้แสดงเมื่อปิดระบบ

func (*Configs) SetConfigAvailableStatus

func (cf *Configs) SetConfigAvailableStatus(status string) error

SetConfigAvailableStatus set config available status สร้าง config สถานะ ปิด/เปิด ระบบ

type DatabaseConfig

type DatabaseConfig struct {
	Host         string        `mapstructure:"HOST"`
	Port         int           `mapstructure:"PORT"`
	Username     string        `mapstructure:"USERNAME"`
	Password     string        `mapstructure:"PASSWORD"`
	DatabaseName string        `mapstructure:"DATABASE_NAME"`
	Timeout      string        `mapstructure:"TIMEOUT"`
	MaxIdleConns int           `mapstructure:"MAX_IDLE_CONNS"`
	MaxOpenConns int           `mapstructure:"MAX_OPEN_CONNS"`
	MaxLifetime  time.Duration `mapstructure:"MAX_LIFE_TIME"`
}

type Environment

type Environment string

Environment environment

const (
	Develop    Environment = "develop"
	Production Environment = "prod"
)

func (Environment) Production

func (e Environment) Production() bool

Production check is production

Jump to

Keyboard shortcuts

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