Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.08 KB

request-and-response.md

File metadata and controls

28 lines (19 loc) · 1.08 KB

Request and response

We use guzzle integration of PSR-7 so read the PSR-7 docs first please it contains almost everything you need to know.

Instead of Psr\Http\Message\ServerRequestInterface and Psr\Http\Message\ResponseInterface use Apitte\Core\Http\ApiRequest and Apitte\Core\Http\ApiResponse in type hints. They add some additional methods.

Response adjusters

Simple static helpers which help you with frequently used response modifications

FileResponseAdjuster

  • Sets headers required to recognize file properly
  • Disables caching of given response
  • See guzzle/psr7 docs for available streams
use Apitte\Core\Adjuster\FileResponseAdjuster;
use Contributte\Psr7\Psr7ResponseFactory;
use function GuzzleHttp\Psr7\stream_for;

$response = Psr7ResponseFactory::fromGlobal();
$stream = stream_for(fopen('/tmp/test.json', 'r+'));
$response = FileResponseAdjuster::adjust($response, $stream, 'filename.json', 'application/json');