config

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: Apache-2.0, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIGETConfig added in v0.0.5

func APIGETConfig(c *gin.Context)

APIGETConfig 返回系统配置项 @since 0.0.4

func GetTablePrefix added in v0.0.5

func GetTablePrefix(dbID string) string

func HTMLRender

func HTMLRender() render.HTMLRender

HTMLRender 从配置文件配置该中间件 @since 0.0.1

func Register added in v0.0.5

func Register(path ...string) error

Register 进行配置 @since 0.0.1 @since 0.0.4 change name func SetConfig(ctx context.Context, path ...string) error {

func SetDatabases

func SetDatabases() (err error)

SetDatabases 设置数据库 和对应的 db TODO 去重 @since 0.0.1

func SetGin

func SetGin()

SetGin 设置 Gin 相关配置 @since 0.0.1

func SetLog

func SetLog()

SetLog 根据配置文件取 @since 0.0.1 @since 0.0.4 解决windows下 控制台输出编码问题

Types

type Config

type Config struct {
	Databases Databases `json:"databases"`
	System    System    `json:"system"`
	Gin       Gin       `json:"gin"`
	SQL       SQL       `json:"sql"`
}

Config 配置

var (
	// Conf 配置
	Conf *Config

	// DefConf 默认配置
	DefConf Config

	// Cookie 配置
	// @since 0.0.2
	Cookie = cookie{
		MaxAge:   1 * 60 * 60,
		Path:     "/",
		Domain:   "",
		Secure:   false,
		HTTPOnly: false,
	}
)

@since 0.0.1

func DefaultConf

func DefaultConf() Config

DefaultConf 默认配置 这里待考虑 是写在内存里还是流出配置文件 考虑的结果是为了防止文件缺失的问题写到内存里 conf.default.json 依旧在包里供查阅 @since 0.0.1

func LoadConf

func LoadConf(path string) *Config

LoadConf 加载配置文件 @since 0.0.1

type Database

type Database struct {
	DBID        string  `json:"db_id"`
	Driver      string  `json:"driver"`
	Name        string  `json:"name"`
	User        string  `json:"user"`
	Password    string  `json:"password"`
	Host        string  `json:"host"`
	Port        string  `json:"port"`
	Charset     string  `json:"charset"`
	TablePrefix string  `json:"table_prefix"`
	DB          *sql.DB `json:"-"`
}

Database 数据库配置 @since 0.0.1

func (Database) DataSourceName

func (d Database) DataSourceName() string

DataSourceName 获取数据库连接字符串 @since 0.0.1

func (Database) DataSourceNameGORM

func (d Database) DataSourceNameGORM() string

DataSourceNameGORM 因为系统 SQL 和 GORM DNS 不一样 见下连接 详细原因待查 @since 0.0.1

type Databases

type Databases []Database

func (Databases) Get

func (d Databases) Get(dbID string) (Database, error)

Get 获取 db 操作句柄 @since 0.0.1

type Gin

type Gin struct {
	Template Template `json:"template"`
	Static   []Static `json:"static"`
}

Gin 相关的配置 @since 0.0.1

type SQL

type SQL struct {
}

@since 0.0.1

type Static

type Static struct {
	RelativePath string `json:"relative_path"`
	Root         string `json:"root"`
}

Static 静态文件目录 @since 0.0.1

type System

type System struct {
	Mode    string `json:"mode"`
	Cache   bool   `json:"cache"`
	Port    string `json:"port"`
	CDNPath string `json:"cdn_path"`
	//@since 0.0.6
	Wechat  bool   `json:"wechat"`
	Version string `json:"version`
}

System 系统配置 @since 0.0.1 @since 0.0.6 增加 echat 开关

增加 Version 版本号

type Template

type Template struct {
	Root         string `json:"root"`
	Master       string `json:"master"`
	Extension    string `json:"extension"`
	DisableCache bool   `json:"disable_cache"`
}

Template 模板配置 @since 0.0.1

Jump to

Keyboard shortcuts

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