🎨优化以下
This commit is contained in:
parent
8de68413c1
commit
fb97082c0c
@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
type redis struct {
|
type cache struct {
|
||||||
|
Type string `yaml:"type"`
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
@ -5,7 +5,7 @@ var Config *config
|
|||||||
type config struct {
|
type config struct {
|
||||||
Http *http `yaml:"http"`
|
Http *http `yaml:"http"`
|
||||||
Database *database `yaml:"database"`
|
Database *database `yaml:"database"`
|
||||||
Redis *redis `yaml:"redis"`
|
Cache *cache `yaml:"redis"`
|
||||||
File *file `yaml:"file"`
|
File *file `yaml:"file"`
|
||||||
Mail *mail `yaml:"email"`
|
Mail *mail `yaml:"email"`
|
||||||
Wireguard *wireguard `yaml:"wireguard"`
|
Wireguard *wireguard `yaml:"wireguard"`
|
||||||
|
@ -29,7 +29,7 @@ func Authorization() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果token的颁发者与请求的站点不一致,则直接给它狗日的丢出去
|
// 如果token的颁发者与请求的站点不一致那么就给它抬出去
|
||||||
if userClaims.Issuer != utils.WebSite().GetHost(c.Request.Header.Get("Referer")) {
|
if userClaims.Issuer != utils.WebSite().GetHost(c.Request.Header.Get("Referer")) {
|
||||||
response.R(c).AuthorizationFailed("未登陆")
|
response.R(c).AuthorizationFailed("未登陆")
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
@ -105,9 +105,9 @@ func initDatabase() {
|
|||||||
// @description: 初始化redis
|
// @description: 初始化redis
|
||||||
func initRedis() {
|
func initRedis() {
|
||||||
c := redis.NewClient(&redis.Options{
|
c := redis.NewClient(&redis.Options{
|
||||||
Addr: fmt.Sprintf("%s:%d", config.Config.Redis.Host, config.Config.Redis.Port),
|
Addr: fmt.Sprintf("%s:%d", config.Config.Cache.Host, config.Config.Cache.Port),
|
||||||
Password: config.Config.Redis.Password,
|
Password: config.Config.Cache.Password,
|
||||||
DB: config.Config.Redis.Db,
|
DB: config.Config.Cache.Db,
|
||||||
})
|
})
|
||||||
|
|
||||||
client.Redis = c
|
client.Redis = c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user