|
@@ 57-66 (lines=10) @@
|
| 54 |
|
*/ |
| 55 |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 56 |
|
{ |
| 57 |
|
if (null === $accept = $this->acceptNegotiator->negotiate($request)) { |
| 58 |
|
$supportedMediaTypes = $this->acceptNegotiator->getSupportedMediaTypes(); |
| 59 |
|
return $this->responseManager->createFromApiProblem( |
| 60 |
|
new NotAcceptable( |
| 61 |
|
$request->getHeaderLine('Accept'), |
| 62 |
|
$supportedMediaTypes |
| 63 |
|
), |
| 64 |
|
$supportedMediaTypes[0] |
| 65 |
|
); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
$request = $request->withAttribute('accept', $accept->getValue()); |
| 69 |
|
|
|
@@ 71-79 (lines=9) @@
|
| 68 |
|
$request = $request->withAttribute('accept', $accept->getValue()); |
| 69 |
|
|
| 70 |
|
if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true)) { |
| 71 |
|
if (null === $contentType = $this->contentTypeNegotiator->negotiate($request)) { |
| 72 |
|
return $this->responseManager->createFromApiProblem( |
| 73 |
|
new UnsupportedMediaType( |
| 74 |
|
$request->getHeaderLine('Content-Type'), |
| 75 |
|
$this->contentTypeNegotiator->getSupportedMediaTypes() |
| 76 |
|
), |
| 77 |
|
$accept->getValue() |
| 78 |
|
); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
$request = $request->withAttribute('contentType', $contentType->getValue()); |
| 82 |
|
} |