From 4b44e3ca7fb655b6ab3f0dd9d4b2efd594e489b0 Mon Sep 17 00:00:00 2001 From: dark Date: Mon, 14 Jul 2025 04:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=A0=E5=85=A5token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/handler.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/handler.tpl b/api/handler.tpl index 4b62e9b..fc952e5 100644 --- a/api/handler.tpl +++ b/api/handler.tpl @@ -15,6 +15,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) return } + {{end}} // 获取请求头里的token token := r.Header.Get("Authorization") // 如果有token, 使用context传值到logic中 @@ -22,7 +23,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { ctx := context.WithValue(r.Context(), "token", token) r = r.WithContext(ctx) } - {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) + l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) {{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}}) if err != nil { httpx.ErrorCtx(r.Context(), w, err)