1 Star 1 Fork 1

K/ginorigin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
security.go 876 Bytes
一键复制 编辑 原始数据 按行查看 历史
K 提交于 2022-02-27 21:16 . (*)模块化
package security
import (
"errors"
"time"
"gitee.com/chenhonghua/ginorigin/config/system/zap"
)
var (
IsServerRunning bool
securityConfig SecurityConfig
)
type SecurityConfig struct {
Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` // 是否开启
EnableRedisCache bool `mapstructure:"enable-redis-cache" json:"enableRedisCache" yaml:"enable-redis-cache"` // 是否开启redis缓存
}
func (c SecurityConfig) Load() {
securityConfig = c
if !securityConfig.Enable {
return
}
zap.LOGGER.Info("security模块:", zap.Any("config", securityConfig))
routerInit()
createTalbes()
go func() {
for !IsServerRunning {
time.Sleep(time.Duration(10) * time.Microsecond)
}
importMetaData()
}()
}
func checkEnable() {
if !securityConfig.Enable {
panic(errors.New("未启用security模块"))
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/chenhonghua/ginorigin.git
git@gitee.com:chenhonghua/ginorigin.git
chenhonghua
ginorigin
ginorigin
v0.1.1

搜索帮助