public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $contentType = $request->getHeaderLine('Content-Type');

        if (!$this->match($contentType)) {
            return $delegate->process($request);
        }

        $rawBody = (string)$request->getBody();
        $parsedBody = json_decode($rawBody, true);

        if (!empty($rawBody) && json_last_error() !== JSON_ERROR_NONE) {
            $statusCode = 400;
            $apiMessage = new HttpStatusCodeApiMessage($statusCode);
            $apiMessage->setCode('invalid-json');
            $apiMessage->setValue('Invalid JSON');
            $apiResponse = $this->newPsrResponseWithTranslatedMessages->__invoke(
                null,
                $statusCode,
                $apiMessage
            );

            return $apiResponse;
        }

        $request = $request
            ->withAttribute('rawBody', $rawBody)
            ->withParsedBody($parsedBody);

        return $delegate->process($request);
    }