Skip to content

Commit

Permalink
Change 400 to 404
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Mátyus committed Apr 18, 2024
1 parent 676bc49 commit 107c93c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [Unreleased][unreleased]
#### Changed
* DefaultHandler response code 404 instead 400

#### Added
* CorsPreflightHandlerInterface - resolve multiple service registered handler error
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/DefaultHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class DefaultHandler extends BaseHandler
*/
public function handle(array $params): ResponseInterface
{
return new JsonApiResponse(IResponse::S400_BAD_REQUEST, ['status' => 'error', 'message' => 'Unknown api endpoint']);
return new JsonApiResponse(IResponse::S404_NOT_FOUND, ['status' => 'error', 'message' => 'Unknown api endpoint']);
}
}
2 changes: 1 addition & 1 deletion tests/Handler/DefaultHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testResponse()
{
$defaultHandler = new DefaultHandler();
$result = $defaultHandler->handle([]);
$this->assertEquals(400, $result->getCode());
$this->assertEquals(404, $result->getCode());
$this->assertEquals('application/json', $result->getContentType());
$this->assertEquals('utf-8', $result->getCharset());
$this->assertEquals(['status' => 'error', 'message' => 'Unknown api endpoint'], $result->getPayload());
Expand Down

0 comments on commit 107c93c

Please sign in to comment.