public function __invoke($request, $response)
{
$response->writeHead(200, ['Content-Type' => 'image/gif', 'Cache-Control' => 'no-cache, no-store', 'Pragma' => 'no-cache']);
$gif = $this->createGifStream();
$gif->pipe($response);
$this->gifStreams->attach($gif);
$response->on('close', function () use($gif) {
$this->gifStreams->detach($gif);
$gif->close();
});
}