Skip to content

Commit

Permalink
Add health check condition
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Feb 10, 2020
1 parent 5a4d0b9 commit 75296de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/HealthCheckCondition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace Packaged\Routing;

use Packaged\Context\Context;

class HealthCheckCondition implements Condition
{
public function match(Context $context): bool
{
$r = $context->request();
$hasHeader = false;
$hasHeader = $hasHeader || $r->headers->has('packaged-health-check');
$hasHeader = $hasHeader || stripos($r->userAgent(), 'kube-probe') !== false;
$hasHeader = $hasHeader || stripos($r->userAgent(), 'googlehc') !== false;
$hasHeader = $hasHeader || stripos($r->userAgent(), 'elb-healthchecker') !== false;
return $hasHeader || stripos($r->path(), '_ah/health') !== false;
}
}

0 comments on commit 75296de

Please sign in to comment.