配置接口lang请求头

This commit is contained in:
2026-03-10 11:42:39 +08:00
parent 9452fd28e2
commit 275f94f96d
8 changed files with 178 additions and 10 deletions

View File

@@ -17,6 +17,11 @@ class ApiException extends BusinessException
{
public function render(Request $request): ?Response
{
return json(['code' => $this->getCode() ?: 500, 'message' => $this->getMessage()]);
$message = $this->getMessage();
$path = $request->path();
if (str_contains($path, 'api/')) {
$message = \app\api\util\ApiLang::translate($message, $request);
}
return json(['code' => $this->getCode() ?: 500, 'message' => $message]);
}
}