Skip to content

Commit 69b8b61

Browse files
author
Philipp Marien
committed
refactoring for version 3.0.0
1 parent e07fefc commit 69b8b61

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/JsonApiServer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Enm\JsonApi\Server;
55

66
use Enm\JsonApi\Exception\BadRequestException;
7+
use Enm\JsonApi\Exception\UnsupportedMediaTypeException;
78
use Enm\JsonApi\Exception\UnsupportedTypeException;
89
use Enm\JsonApi\JsonApiTrait;
910
use Enm\JsonApi\Model\Document\DocumentInterface;
@@ -76,9 +77,14 @@ public function addHandler(string $type, RequestHandlerInterface $handler): void
7677
* @return ResponseInterface
7778
* @throws BadRequestException
7879
* @throws UnsupportedTypeException
80+
* @throws UnsupportedMediaTypeException
7981
*/
8082
public function handleRequest(RequestInterface $request): ResponseInterface
8183
{
84+
if ($request->headers()->getRequired('Content-Type') !== 'application/vnd.api+json') {
85+
throw new UnsupportedMediaTypeException($request->headers()->getRequired('Content-Type'));
86+
}
87+
8288
switch ($request->method()) {
8389
case 'GET':
8490
if ($request->id()) {

0 commit comments

Comments
 (0)