Slim PHP
/pixel.gif కు వచ్చే రిక్వెస్ట్లకు empty GIF తో జవాబిచ్చే, Slim కోసం PHP స్నిపెట్. GIF స్టార్టప్లో ఒక్కసారే డీకోడ్ అవుతుంది.
Slim PHP
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
require __DIR__ . '/vendor/autoload.php';
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
$app = AppFactory::create();
$app->get('/pixel.gif', function (Request $request, Response $response) use ($gif) {
$response->getBody()->write($gif);
return $response
->withHeader('Content-Type', 'image/gif')
->withHeader('Content-Length', (string) strlen($gif))
->withHeader('Cache-Control', 'no-store');
});
$app->run();
మేము ఈ స్నిపెట్ను రన్ చేసి, అది తిరిగి ఇచ్చిన బైట్లను పోల్చి చూశాం.
చెక్ చేయండి
curl -sI http://localhost:8080/pixel.gif