Documentation ¶
Index ¶
- Constants
- func FailWithCode(code int, c *gin.Context)
- func FailWithDetailed(code int, data interface{}, message string, c *gin.Context)
- func FailWithMessage(code int, message string, c *gin.Context)
- func Ok(c *gin.Context)
- func OkWithData(data interface{}, c *gin.Context)
- func OkWithDetailed(data interface{}, message string, c *gin.Context)
- func OkWithMessage(message string, c *gin.Context)
- func Result(code int, data interface{}, msg string, c *gin.Context)
- type ByID
- type ByIDS
- type Config
- type Email
- type Environment
- type Etcd
- type Log
- type Mysql
- type PageInfo
- type PageResult
- type Redis
- type Response
- type System
- type WebHook
Constants ¶
View Source
const ( ExtensionJson = ".json" ExtensionYaml = ".yaml" ExtensionInI = ".ini" NameSpace = "conf" )
View Source
const ( EnvTesting = Environment("testing") EnvProduction = Environment("production") )
use export ENVIRONMENT=testing set global environment
View Source
const ( SUCCESS = 200 ERROR = 1000 ErrorRequestParameter = 1001 ErrorTokenGenerate = 1002 ErrorUserNameExist = 1003 )
View Source
const ( Version = "v1.1.0" ApiModule = "common/api-server" )
Variables ¶
This section is empty.
Functions ¶
func FailWithCode ¶
func FailWithDetailed ¶
func OkWithData ¶
func OkWithDetailed ¶
func OkWithMessage ¶
Types ¶
type Config ¶
type Config struct { WebHook WebHook `mapstructure:"webhook" json:"webhook" yaml:"webhook" ini:"webhook"` Log Log `mapstructure:"log" json:"log" yaml:"log" ini:"log"` Email Email `mapstructure:"email" json:"email" yaml:"email" ini:"email"` System System `mapstructure:"system" json:"system" yaml:"system" ini:"system"` Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql" ini:"mysql"` Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis" ini:"redis"` Etcd Etcd `mapstructure:"etcd" json:"etcd" yaml:"etcd" ini:"etcd"` }
func GetConfigModels ¶
func GetConfigModels() *Config
func LoadConfig ¶
type Email ¶
type Email struct { Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 From string `mapstructure:"from" json:"from" yaml:"from"` // 收件人 Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址 IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"` // 是否SSL Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥 Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称 To []string `mapstructure:"to" json:"to" yaml:"to" ini:"to"` }
type Environment ¶
type Environment string
func NewGlobalEnvironment ¶
func NewGlobalEnvironment() (Environment, error)
NewGlobalEnvironment 读取系统全局配置的环境变量
func (Environment) Invalid ¶
func (env Environment) Invalid() bool
func (*Environment) Production ¶
func (env *Environment) Production() Environment
func (*Environment) String ¶
func (env *Environment) String() string
func (*Environment) Testing ¶
func (env *Environment) Testing() Environment
type Etcd ¶
type Etcd struct { Endpoints []string `mapstructure:"endpoints" json:"endpoints" yaml:"endpoints" ini:"endpoints"` Username string `mapstructure:"username" json:"username" yaml:"username" ini:"username"` Password string `mapstructure:"password" json:"password" yaml:"password" ini:"password"` DialTimeout int64 `mapstructure:"dial-timeout" json:"dial-timeout" yaml:"dial-timeout" ini:"dial-timeout"` ReqTimeout int64 `mapstructure:"req-timeout" json:"req-timeout" yaml:"req-timeout" ini:"req-timeout"` }
type Log ¶
type Log struct { Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出 Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀 Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹 ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"` // 显示行 EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` // 栈名 LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"` // 输出控制台 }
type Mysql ¶
type Mysql struct { Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址 Port string `mapstructure:"port" json:"port" yaml:"port"` // 端口 Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置 Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名 Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数 MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` // 是否通过zap写入日志文件 }
type PageInfo ¶
type PageInfo struct { Page int `json:"page" form:"page"` // 页码 PageSize int `json:"page_size" form:"page_size"` // 每页大小 }
PageInfo Paging common input parameter structure
type PageResult ¶
Click to show internal directories.
Click to hide internal directories.