Equip\Responder\FormattedResponder::format PHP Method

format() protected method

Update the response by formatting the payload.
protected format ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, Equip\Adr\PayloadInterface $payload ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$payload Equip\Adr\PayloadInterface
return Psr\Http\Message\ResponseInterface
    protected function format(ServerRequestInterface $request, ResponseInterface $response, PayloadInterface $payload)
    {
        $formatter = $this->formatter($request);
        $response = $response->withHeader('Content-Type', $formatter->type());
        // Overwrite the body instead of making a copy and dealing with the stream.
        $response->getBody()->write($formatter->body($payload));
        return $response;
    }