From bea96a37b71d1da218b1f657bb7088e5c72bfee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F=E4=B9=90?= Date: Wed, 29 Mar 2023 17:57:52 +0800 Subject: [PATCH] x --- api/user.http.go | 4 ++-- api/user_http.pb.go | 6 +++--- cmd/kit/main.go | 4 ++-- middleware/logging/logging.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/user.http.go b/api/user.http.go index 8b370b5..83b2528 100644 --- a/api/user.http.go +++ b/api/user.http.go @@ -1,11 +1,11 @@ package user import ( - "git.diulo.com/mogfee/kit/response" - "github.com/gin-gonic/gin" "context" "git.diulo.com/mogfee/kit/middleware" "git.diulo.com/mogfee/kit/errors" + "git.diulo.com/mogfee/kit/response" + "github.com/gin-gonic/gin" ) func RegisterUserHandler(app *gin.Engine, srv UserServer, m ...middleware.Middleware) { diff --git a/api/user_http.pb.go b/api/user_http.pb.go index 16c7855..ece64b6 100644 --- a/api/user_http.pb.go +++ b/api/user_http.pb.go @@ -22,8 +22,8 @@ func _User_List0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { var in LoginRequest //user:list var newCtx context.Context = ctx - newCtx = jwt.SetAuthKeyContext(ctx, "user:list") - newCtx = jwt.SetNeedAuthContext(ctx, true) + newCtx = jwt.SetAuthKeyContext(newCtx, "user:list") + newCtx = jwt.SetNeedAuthContext(newCtx, true) if err := ctx.BindQuery(&in); err != nil { return err } @@ -43,7 +43,7 @@ func _User_Login0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error return func(ctx http.Context) error { var in LoginRequest var newCtx context.Context = ctx - newCtx = jwt.SetNeedAuthContext(ctx, true) + newCtx = jwt.SetNeedAuthContext(newCtx, true) if err := ctx.BindQuery(&in); err != nil { return err } diff --git a/cmd/kit/main.go b/cmd/kit/main.go index a7c432a..6460df3 100644 --- a/cmd/kit/main.go +++ b/cmd/kit/main.go @@ -111,9 +111,9 @@ func (u *Kit) genGet(f *protogen.File, s *protogen.Service, t *protogen.Generate t.P("//", authKey) t.P(`var newCtx context.Context=ctx`) if authKey != "" { - t.P(`newCtx = jwt.SetAuthKeyContext(ctx, "`, authKey, `")`) + t.P(`newCtx = jwt.SetAuthKeyContext(newCtx, "`, authKey, `")`) } - t.P(`newCtx = jwt.SetNeedAuthContext(ctx, `, needAuth, `)`) + t.P(`newCtx = jwt.SetNeedAuthContext(newCtx, `, needAuth, `)`) if method == protogen2.METHOD_GET { t.P(`if err := ctx.BindQuery(&in); err != nil { return err diff --git a/middleware/logging/logging.go b/middleware/logging/logging.go index 30bf5ad..8a21eb5 100644 --- a/middleware/logging/logging.go +++ b/middleware/logging/logging.go @@ -8,7 +8,7 @@ import ( func Server() middleware.Middleware { return func(handler middleware.Handler) middleware.Handler { return func(ctx context.Context, a any) (any, error) { - ctx = context.WithValue(ctx, "user-id", "1111") + return handler(ctx, a) } }