|
@@ -65,21 +65,27 @@ class SensitiveMiddleware implements MiddlewareInterface
|
|
|
continue;
|
|
|
}
|
|
|
if (str_contains($concatenated, $badWord)) {
|
|
|
- return $this->response->json([
|
|
|
- 'code' => 0,
|
|
|
- 'data' => [],
|
|
|
- 'message' => '发现违禁词: ' . $badWord
|
|
|
- ]);
|
|
|
+ $response = $this->response->withStatus(200)
|
|
|
+ ->withHeader('Content-Type', 'application/json')
|
|
|
+ ->withBody(new SwooleStream(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ 'data' => [],
|
|
|
+ 'message' => '发现违禁词: ' . $badWord
|
|
|
+ ])));
|
|
|
+ return $response;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $handler->handle($request);
|
|
|
} catch (\Exception $e) {
|
|
|
- return $this->response->json([
|
|
|
- 'code' => -1,
|
|
|
- 'data' => [],
|
|
|
- 'message' => '系统错误:' . $e->getMessage()
|
|
|
- ]);
|
|
|
+ $response = $this->response->withStatus(200)
|
|
|
+ ->withHeader('Content-Type', 'application/json')
|
|
|
+ ->withBody(new SwooleStream(json_encode([
|
|
|
+ 'code' => -1,
|
|
|
+ 'data' => [],
|
|
|
+ 'message' => '系统错误:' . $e->getMessage()
|
|
|
+ ])));
|
|
|
+ return $response;
|
|
|
}
|
|
|
}
|
|
|
}
|