webman迁移-优化
This commit is contained in:
@@ -87,7 +87,14 @@ abstract class BaseController
|
||||
unset($header['statusCode']);
|
||||
|
||||
$headers = array_merge(['Content-Type' => 'application/json'], $header);
|
||||
$jsonBody = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
|
||||
if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
|
||||
$options |= JSON_INVALID_UTF8_SUBSTITUTE;
|
||||
}
|
||||
$jsonBody = json_encode($body, $options);
|
||||
if ($jsonBody === false) {
|
||||
$jsonBody = '{"code":0,"msg":"JSON encode error","time":' . time() . ',"data":[]}';
|
||||
}
|
||||
|
||||
return response($jsonBody, $statusCode, $headers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user