From fb97082c0c419de38818fc182dfc9daf9531b628 Mon Sep 17 00:00:00 2001 From: coward Date: Thu, 11 Jul 2024 16:21:08 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E4=BC=98=E5=8C=96=E4=BB=A5=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/{redis.go => cache.go} | 3 ++- config/config.go | 2 +- http/middleware/authorization.go | 2 +- initialize/init.go | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) rename config/{redis.go => cache.go} (73%) diff --git a/config/redis.go b/config/cache.go similarity index 73% rename from config/redis.go rename to config/cache.go index 728defb..ae97dfd 100644 --- a/config/redis.go +++ b/config/cache.go @@ -1,6 +1,7 @@ package config -type redis struct { +type cache struct { + Type string `yaml:"type"` Host string `yaml:"host"` Port int `yaml:"port"` Password string `yaml:"password"` diff --git a/config/config.go b/config/config.go index b7f7409..29d36c0 100644 --- a/config/config.go +++ b/config/config.go @@ -5,7 +5,7 @@ var Config *config type config struct { Http *http `yaml:"http"` Database *database `yaml:"database"` - Redis *redis `yaml:"redis"` + Cache *cache `yaml:"redis"` File *file `yaml:"file"` Mail *mail `yaml:"email"` Wireguard *wireguard `yaml:"wireguard"` diff --git a/http/middleware/authorization.go b/http/middleware/authorization.go index fbf5a72..24719db 100644 --- a/http/middleware/authorization.go +++ b/http/middleware/authorization.go @@ -29,7 +29,7 @@ func Authorization() gin.HandlerFunc { return } - // 如果token的颁发者与请求的站点不一致,则直接给它狗日的丢出去 + // 如果token的颁发者与请求的站点不一致那么就给它抬出去 if userClaims.Issuer != utils.WebSite().GetHost(c.Request.Header.Get("Referer")) { response.R(c).AuthorizationFailed("未登陆") c.Abort() diff --git a/initialize/init.go b/initialize/init.go index cd99c1d..5060a2f 100644 --- a/initialize/init.go +++ b/initialize/init.go @@ -105,9 +105,9 @@ func initDatabase() { // @description: 初始化redis func initRedis() { c := redis.NewClient(&redis.Options{ - Addr: fmt.Sprintf("%s:%d", config.Config.Redis.Host, config.Config.Redis.Port), - Password: config.Config.Redis.Password, - DB: config.Config.Redis.Db, + Addr: fmt.Sprintf("%s:%d", config.Config.Cache.Host, config.Config.Cache.Port), + Password: config.Config.Cache.Password, + DB: config.Config.Cache.Db, }) client.Redis = c