Documentation
¶
Overview ¶
config 系统底层的配置文件相关模块 支持第三方应用的 kv 配置 支持定义各种数据库连接格式 做了些基础设置和模板函数
Index ¶
- func APIGETConfig(c *gin.Context)
- func Authorization() gin.HandlerFunc
- func CORS() gin.HandlerFunc
- func GetTablePrefix(dbID string) string
- func HTMLRender() render.HTMLRender
- func Register(path ...string) error
- func SetDatabases() (err error)
- func SetGin()
- func SetLog()
- type CORSConfig
- type Config
- type Database
- type Databases
- type Gin
- type KV
- type KVS
- type SQL
- type Static
- type System
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authorization ¶
func Authorization() gin.HandlerFunc
func CORS ¶
func CORS() gin.HandlerFunc
CORS returns the location middleware with default configuration. @since v0.0.9
func Register ¶
Register 进行配置 @since 0.0.1 @since 0.0.4 change name func SetConfig(ctx context.Context, path ...string) error {
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowOrigins []string `json:"allow-origins"`
AllowMethods []string `json:"allow-methods"`
AllowHeaders []string `json:"allow-headers"`
}
@since 0.0.10 增加跨域的配置项
type Config ¶
type Config struct {
Databases Databases `json:"databases"`
System System `json:"system"`
Gin Gin `json:"gin"`
SQL SQL `json:"sql"`
// @since 0.0.10
CORS CORSConfig `json:"cors"`
// @since 0.0.11
KV KVS `json:"kv"`
}
Config 配置 @since 0.0.10 增加跨域功能
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
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 ¶
DataSourceName 获取数据库连接字符串 @since 0.0.1 @since 0.0.10 取消 dburl 的引用
type Gin ¶
Gin 相关的配置 @since 0.0.1
type Static ¶
type Static struct {
RelativePath string `json:"relative_path"`
Root string `json:"root"`
Type string `json:"type"`
}
Static 静态文件目录 @since 0.0.1 @since 0.0.10 支持单个静态文件
Source Files
¶
- config.go
- default.go
- gin.go
- gin_static.go
- gin_template.go
Click to show internal directories.
Click to hide internal directories.