config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Log: Log{
		Level: "debug",
		Dir:   "./logs",
	},
	Server: Server{
		Address:     ":443",
		Header:      "OpenCloudflareCDN",
		HttpAddress: ":80",
	},
	StaticPath:     "./static",
	StaticIndex:    "index.html",
	OriginalServer: "https://example.com",
	JWTSecret:      "your-super-secret-and-long-key",
}
View Source
var ErrConfigNotFound = errors.New("config file not found")

Functions

func Init

func Init(loaders ...Loader) error

Types

type Config

type Config struct {
	IsDefault  bool   `json:"-" optional:"true" yaml:"-"`
	ConfigPath string `json:"-" optional:"true" yaml:"-"`

	Log                Log    `json:"log"                optional:"true"           yaml:"log"`
	Server             Server `json:"server"             yaml:"server"`
	StaticPath         string `json:"staticPath"         yaml:"staticPath"`
	StaticIndex        string `json:"staticIndex"        optional:"true"           yaml:"staticIndex"`
	OriginalServer     string `json:"OriginalServer"     yaml:"OriginalServer"`
	TurnstileSiteKey   string `json:"turnstileSiteKey"   yaml:"turnstileSiteKey"`
	TurnstileSecretKey string `json:"turnstileSecretKey" yaml:"turnstileSecretKey"`
	JWTSecret          string `json:"jwtSecret"          yaml:"jwtSecret"`
}
var Instance *Config

func NewConfig

func NewConfig(loaders ...Loader) (*Config, error)

type Loader

type Loader interface {
	Load(cfg *Config, fileName string) error
	Save(cfg *Config, fileName string) error
	// GetAllowFileExtensions lowercase
	GetAllowFileExtensions() []string
}

type Log

type Log struct {
	Level string `json:"level" optional:"true" yaml:"level"`
	Dir   string `json:"dir"   optional:"true" yaml:"dir"`
}

type Server

type Server struct {
	Address     string `json:"address"     yaml:"address"`
	Header      string `json:"header"      optional:"true" yaml:"header"`
	HttpAddress string `json:"httpAddress" optional:"true" yaml:"httpAddress"`
	TLS         TLS    `json:"tls"         optional:"true" yaml:"tls"`
}

type TLS

type TLS struct {
	Cert string `json:"cert" yaml:"cert"`
	Key  string `json:"key"  yaml:"key"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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