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