-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d5783a3
commit f0cee42
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/Protocols/Pusher/Http/Controllers/HealthCheckController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Laravel\Reverb\Protocols\Pusher\Http\Controllers; | ||
|
||
use Laravel\Reverb\Servers\Reverb\Http\Connection; | ||
use Laravel\Reverb\Servers\Reverb\Http\Response; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
class HealthCheckController extends Controller | ||
{ | ||
/** | ||
* Handle the request. | ||
*/ | ||
public function __invoke(RequestInterface $request, Connection $connection): Response | ||
{ | ||
return new Response((object) ['health' => 'OK']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/Feature/Protocols/Pusher/Reverb/HealthCheckControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Laravel\Reverb\Tests\ReverbTestCase; | ||
|
||
use function React\Async\await; | ||
|
||
uses(ReverbTestCase::class); | ||
|
||
it('fails when server is not running', function () { | ||
$this->stopServer(); | ||
await($this->requestWithoutAppId('up')); | ||
})->throws(RuntimeException::class); | ||
|
||
it('can respond to a health check request', function () { | ||
$response = await($this->requestWithoutAppId('up')); | ||
|
||
expect($response->getStatusCode())->toBe(200); | ||
expect($response->getBody()->getContents())->toBe('{"health":"OK"}'); | ||
expect($response->getHeader('Content-Length'))->toBe(['15']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters