configs

package
v0.0.0-...-8e1329c Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

type CORS struct {
	Enable           bool   `yaml:"enable"`
	AllowOrigins     string `yaml:"allow_origins"`
	AllowMethods     string `yaml:"allow_methods"`
	AllowHeaders     string `yaml:"allow_headers"`
	AllowCredentials bool   `yaml:"allow_credentials"`
	MaxAge           int    `yaml:"max_age"`
}

CORS 跨域请求配置参数

type DatabaseConfig

type DatabaseConfig struct {
	Dialect      string `yaml:"dialect"`
	Host         string `yaml:"host"`
	Port         int    `yaml:"port"`
	Database     string `yaml:"database"`
	User         string `yaml:"user"`
	Password     string `yaml:"password"`
	MaxOpenConns int    `yaml:"max_open_conns"` //最大链接数.
	MaxIdleConns int    `yaml:"max_idle_conns"` //最大闲置链接数
	Debug        bool
}

DatabaseConfig 数据库配置.

func (*DatabaseConfig) ToURL

func (p *DatabaseConfig) ToURL() (url string)

ToURL 获取dns链接

type ServerConfig

type ServerConfig struct {
	Listen            string
	LogLevel          string `yaml:"log_level"`
	LogFileName       string `yaml:"log_filename"`
	CheckSign         bool   `yaml:"check_sign"`
	Debug             bool   `yaml:"debug"`
	DisableStacktrace bool   `yaml:"disable_stacktrace"`
	URLSign           bool   `yaml:"url_sign"`
	CheckCaptcha      bool   `yaml:"check_captcha"`
	ServerEnv         string `yaml:"server_env"`

	// 客户端测试账号,(不会真正发送验证码) key为手机号, value为验证码.
	TestAccounts map[string]string `yaml:"test_accounts"`
	// 给单元测试使用的超级验证码, 只在Debug=true时有效.
	SuperCodeForTest string `yaml:"super_code_for_test"`
	// 访问`/v1/man/account/sms/get/code`接口使用的key.
	SuperKeyForTest string `yaml:"super_key_for_test"`
	// 超级签名, 仅用于测试, 只在Debug=true时有效
	SuperSignKey string `yaml:"super_sign_key"`
	// 访问后台接口(以 `/v1/man/` 开头的)需要使用该token.
	AdminToken string `yaml:"admin_token"`

	InviteCodeSettingPeriod time.Duration `yaml:"invite_code_setting_period"`

	ReqDebug     bool          `yaml:"req_debug"`      //是否开启请求日志
	ReqDebugHost string        `yaml:"req_debug_host"` //host值, 默认为: https://127.0.0.1:2021
	ReqDebugDir  string        `yaml:"req_debug_dir"`  //目录值, 默认为: /data/logs/req_debug/
	FdExpiretime time.Duration `yaml:"fd_expiretime"`  //文件句柄过期时间,默认为10分钟.

	InviteCodeLength int `yaml:"invite_code_length"` // 生成的邀请码长度

	AccountDB  *DatabaseConfig    `yaml:"account_database"` //mysql 链接配置.
	TokenRedis *cache.RedisConfig `yaml:"token_redis"`      // TOKEN
	SmsRedis   *cache.RedisConfig `yaml:"sms_redis"`

	CORS CORS `yaml:"cors"`

	// appID及对应的sign key
	AppKeys     map[string]string `yaml:"app_keys"`
	SignHeaders []string          `yaml:"sign_headers"` //需要参与签名的请求头列表

	CustomHeaderPrefix string `yaml:"custom_header_prefix"` //自定义请求头的前缀(默认为X-OA-)
}

ServerConfig 服务器配置

var Config *ServerConfig

Config 全局配置

func LoadConfig

func LoadConfig(configFilename string) (config *ServerConfig, err error)

LoadConfig 加载解析配置.

func (*ServerConfig) GetSignKey

func (a *ServerConfig) GetSignKey(appID string) string

GetSignKey 获取应用的signKey

Jump to

Keyboard shortcuts

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