HttpCoreMiddleware.php 774 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\JsonRpc;
  12. use Psr\Http\Message\ServerRequestInterface;
  13. class HttpCoreMiddleware extends CoreMiddleware
  14. {
  15. protected function handleNotFound(ServerRequestInterface $request): mixed
  16. {
  17. // @TODO Allow more health check conditions.
  18. if ($request->getHeaderLine('user-agent') === 'Consul Health Check') {
  19. // The request that from health checker, return 200 directly.
  20. return $this->response()->withStatus(200);
  21. }
  22. return parent::handleNotFound($request);
  23. }
  24. }