From 29bf07973128f16bf92aebd057d5d5cdffde4c65 Mon Sep 17 00:00:00 2001 From: u2nyakim Date: Fri, 29 Aug 2025 15:53:02 +0800 Subject: [PATCH] =?UTF-8?q?up.=20=E5=8F=8C=E5=90=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/middleware/ContextMiddleware.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/http/middleware/ContextMiddleware.php b/app/http/middleware/ContextMiddleware.php index 882342e..c7e2a17 100644 --- a/app/http/middleware/ContextMiddleware.php +++ b/app/http/middleware/ContextMiddleware.php @@ -12,20 +12,13 @@ class ContextMiddleware extends middleware public function handle(Request $request, Closure $next): Response { - /* * 生成并绑定全局上下文标识ID */ $request->contextId = unique_str(); - /** - * @var Response $response - */ - $response = $next($request); - $response->header([ - 'R-Context-Id' => $request->contextId, - ]); + /* - * 数据已加密 + * 数据已加密, 需要先做解密传递处理 */ if ($request->header('x-encrypted') == 'true') { $encryptedData = $request->param('encryptedData',''); @@ -34,6 +27,15 @@ class ContextMiddleware extends middleware $request->withPost($jsonData); } } + + /** + * @var Response $response + */ + $response = $next($request); + $response->header([ + 'R-Context-Id' => $request->contextId, + ]); + return $response; }