From 4a3201109fe92f70c3a6ab7d52b7aa9240750b4f Mon Sep 17 00:00:00 2001 From: gaowenju Date: Fri, 17 May 2024 15:34:38 +0800 Subject: [PATCH] feat: only recover in sd mode --- client/localsession.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/localsession.go b/client/localsession.go index d43750e..2cd9e96 100644 --- a/client/localsession.go +++ b/client/localsession.go @@ -18,6 +18,7 @@ package client import ( "context" + "github.com/cloudwego/hertz/pkg/app/client" "github.com/cloudwego/hertz/pkg/protocol" "github.com/cloudwego/localsession/backup" @@ -27,6 +28,10 @@ import ( func CtxRecover(hdl backup.BackupHandler) client.Middleware { return func(next client.Endpoint) client.Endpoint { return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) { + // only recover ctx in sd mode + if !req.Options().IsSD() { + return next(ctx, req, resp) + } ctx = backup.RecoverCtxOnDemands(ctx, hdl) return next(ctx, req, resp) }