config

package
v1.68.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigPath = "simpleDB/config.yaml"

Variables

This section is empty.

Functions

func Save

func Save(path string, config Config) error

Types

type Config

type Config struct {
	Database  DatabaseConfig  `yaml:"database"`
	Transport TransportConfig `yaml:"transport"`
}

func Default

func Default() Config

func Load

func Load(path string) (Config, error)

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

func (Config) ParseLimitWindow

func (c Config) ParseLimitWindow() (time.Duration, error)

func (Config) ParseTokenTTL

func (c Config) ParseTokenTTL() (time.Duration, error)

func (Config) Validate

func (c Config) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	Path string `yaml:"path"`
}

type HTTPConfig

type HTTPConfig struct {
	Enabled      bool            `yaml:"enabled"`
	Address      string          `yaml:"address"`
	GinMode      string          `yaml:"ginMode"`
	Route        HTTPRouteConfig `yaml:"route"`
	Limit        HTTPLimitConfig `yaml:"limit"`
	InitPassword string          `yaml:"initPassword"`
	TokenTTL     string          `yaml:"tokenTTL"`
	TokenSecret  string          `yaml:"tokenSecret"`
	EnableAdmin  bool            `yaml:"enableAdminRoute"`
	EnableReport bool            `yaml:"enableReportRoute"`
	// SQLAllowedOps 控制 /sql/execute 接口允许执行的语句类型。
	// 可选值: select, insert, update, delete, create, drop, truncate, alter
	// 留空表示不限制(默认开放全部,建议生产环境按需收紧)。
	SQLAllowedOps []string `yaml:"sqlAllowedOps"`
}

type HTTPLimitConfig

type HTTPLimitConfig struct {
	Enabled      bool     `yaml:"enabled"`
	Requests     int      `yaml:"requests"`
	Window       string   `yaml:"window"`
	NoTokenPaths []string `yaml:"noTokenPaths"`
}

type HTTPRouteConfig

type HTTPRouteConfig struct {
	Health               string `yaml:"health"`
	Profile              string `yaml:"profile"`
	Login                string `yaml:"login"`
	Register             string `yaml:"register"`
	Refresh              string `yaml:"refresh"`
	Logout               string `yaml:"logout"`
	Activate             string `yaml:"activate"`
	Deactivate           string `yaml:"deactivate"`
	AssignRole           string `yaml:"assignRole"`
	AssignRolePermission string `yaml:"assignRolePermission"`
	InitSDBPassword      string `yaml:"initSDBPassword"`
	SQLExecute           string `yaml:"sql"`
	SQLGrant             string `yaml:"sqlGrant"`
	Admin                string `yaml:"admin"`
	Report               string `yaml:"report"`
}

type TransportConfig

type TransportConfig struct {
	HTTP HTTPConfig `yaml:"http"`
}

Jump to

Keyboard shortcuts

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