Skip to content

Commit

Permalink
Accept json when posting heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrig committed Apr 30, 2024
1 parent 1cb1619 commit 0eb1ab2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- **BREAKING**: Require Laravel 11.
- **BREAKING**: Camel case keys in response.
- Accept json when posting heartbeat.

### Added
- **BREAKING**: Enum `ResultState`.
Expand Down
1 change: 1 addition & 0 deletions src/Heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function send(string $slug, int $minutes = 1): void
} else {
Http::withToken(config('butler.health.heartbeat.token'))
->timeout(5)
->acceptJson()
->post($url)
->onError(function ($response) {
report($response->toException());
Expand Down
2 changes: 2 additions & 0 deletions tests/HeartbeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public function test_send_happy_path()

Http::assertSent(fn (Request $request)
=> $request->method() === 'POST'
&& $request->isJson()
&& $request->hasHeader('Accept', 'application/json')
&& $request->hasHeader('Authorization', 'Bearer secret')
&& $request->url() === 'http://localhost/foobar/2');
}
Expand Down

0 comments on commit 0eb1ab2

Please sign in to comment.