From 47b28e7b57a0f71efed2d36ecffd88aea9708615 Mon Sep 17 00:00:00 2001 From: hoteas Date: Wed, 21 Jul 2021 00:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=96=B0=E5=A2=9E=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E9=85=8D=E7=BD=AE2.0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=A7=84=E5=AE=9A=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application.go | 10 +++++++--- var.go | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/application.go b/application.go index efc5fc9..affa38b 100644 --- a/application.go +++ b/application.go @@ -298,9 +298,13 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) { if len(token) == 32 { sessionId = token } - //http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId+";SameSite=Strict", Path: "/"}) - //http.SetCookie(w, &http.Cookie{Name: "SameSite", Value: "Strict", Path: "/"}) - w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; SameSite=None; Secure") + //没有跨域设置 + if that.Config.GetString("crossDomain") == "" { + http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId, Path: "/"}) + } else { + //跨域允许需要设置cookie的允许跨域 + w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; SameSite=None; Secure") + } } else { sessionId = cookie.Value } diff --git a/var.go b/var.go index 32b1233..004900d 100644 --- a/var.go +++ b/var.go @@ -14,6 +14,13 @@ var Config = Map{ "codeConfig": Map{ "admin": "config/app.json", }, + "codeConfig1": Map{ + "admin": Map{ //默认无,必须,接口类别名称 + "package": "admin", //默认admin,非必须,有则生成代码到此目录,无则采用缺省模式不生成代码只生成接口 + "config": "config/app.json", //默认config/app.json,必须,接口描述配置文件 + "rule": "config/rule.json", //默认config/rule.json,非必须,有则按改规则生成接口,无则按系统内嵌方式生成 + }, + }, "db": Map{ "sqlite": Map{ "path": "config/data.db",