config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteConfig added in v1.0.1

func WriteConfig(file string, cfg Conf) error

写入配置文件

func WriteConfigToByte added in v1.0.1

func WriteConfigToByte(cfg Conf) ([]byte, error)

写入配置文件

Types

type App

type App struct {
	Appname   string `toml:"app_name"`
	Version   string `toml:"version"`
	Debug     bool   `toml:"debug"`
	TimeZone  string `toml:"time_zone"`
	LogFile   string `toml:"log_file"`
	LogLevel  string `toml:"log_level"`
	Assets    string `toml:"assets"`
	CodeTheme string `toml:"code_theme"`
}

type Conf

type Conf struct {
	App     `toml:"app"`
	Server  `toml:"server"`
	File    `toml:"file"`
	User    `toml:"user"`
	Session `toml:"session"`
}

func ReadConfig

func ReadConfig(file string) (Conf, error)

读取配置文件

func ReadConfigByte

func ReadConfigByte(data []byte) (Conf, error)

读取配置文件

type File

type File struct {
	Path   string `toml:"path"`
	Driver string `toml:"driver"`
}

type Server

type Server struct {
	Address          string `toml:"address"`
	CSRFTokenLength  uint8  `toml:"csrf_token_length"`
	CSRFContextKey   string `toml:"csrf_context_key"`
	CSRFCookieName   string `toml:"csrf_cookie_name"`
	CSRFCookiePath   string `toml:"csrf_cookie_path"`
	CSRFCookieMaxAge int    `toml:"csrf_cookie_maxage"`
}

type Session

type Session struct {
	Secret   string `toml:"secret"`
	Key      string `toml:"key"`
	Path     string `toml:"path"`
	MaxAge   int    `toml:"max_age"`
	HttpOnly bool   `toml:"http_only"`
}

type User

type User struct {
	Names []string `toml:"names"`
}

func (User) GetUserPassword added in v1.0.1

func (this User) GetUserPassword(name string) string

账号密码

func (User) GetUsers added in v1.0.1

func (this User) GetUsers() map[string]string

更改密码

func (User) UpdatePassword added in v1.0.1

func (this User) UpdatePassword(name string, pass string) User

更改密码

Jump to

Keyboard shortcuts

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