From 5a7e2cb28081ce808fd09459d64a852a7bae5113 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 31 Jul 2023 10:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B7=A8=E5=9F=9F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=81=E7=AB=AF=E5=8F=A3=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- go.sum | 2 -- init.go | 5 ++++- xiannccda.setting.yml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d013e9e..d2b1e01 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,9 @@ go 1.20 require ( github.com/appleboy/gin-jwt/v2 v2.9.1 + github.com/gin-contrib/cors v1.4.0 github.com/gin-contrib/zap v0.1.0 + github.com/golang/protobuf v1.5.3 github.com/panjf2000/gnet/v2 v2.3.1 github.com/spf13/viper v1.16.0 github.com/swaggo/files v1.0.1 @@ -19,14 +21,12 @@ require ( require ( github.com/KyleBanks/depth v1.2.1 // indirect - github.com/gin-contrib/cors v1.4.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/golang-jwt/jwt/v4 v4.4.3 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index ce29a27..3413569 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/appleboy/gin-jwt/v2 v2.9.1 h1:l29et8iLW6omcHltsOP6LLk4s3v4g2FbFs0koxGWVZs= github.com/appleboy/gin-jwt/v2 v2.9.1/go.mod h1:jwcPZJ92uoC9nOUTOKWoN/f6JZOgMSKlFSHw5/FrRUk= github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4= diff --git a/init.go b/init.go index a8ee379..b630a08 100644 --- a/init.go +++ b/init.go @@ -32,7 +32,10 @@ func InitServer() *gin.Engine { engine := gin.New() - engine.Use(cors.Default()) + conf := cors.DefaultConfig() + conf.AllowHeaders = []string{"*"} + conf.AllowAllOrigins = true + engine.Use(cors.New(conf)) engine.Use(ginzap.Ginzap(zap.L(), time.DateTime, false)) // gin panic 异常处理,默认处理为 engine.Use(ginzap.RecoveryWithZap(zap.L(), true)) diff --git a/xiannccda.setting.yml b/xiannccda.setting.yml index 2cc9a7e..3e71442 100644 --- a/xiannccda.setting.yml +++ b/xiannccda.setting.yml @@ -3,7 +3,7 @@ env: dev # 服务配置 server: # 服务端口 - port: 8080 + port: 9091 # 动力学端口配置 dynamics: ip: 192.168.3.5