Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ $app->add(new \Slim\HttpCache\Cache('public', 86400));
$container = $app->getContainer();

// Register service provider
$container->register(new \Slim\HttpCache\CacheProvider);
$container['cache'] = function () {
return new \Slim\HttpCache\CacheProvider();
};

// Example route with ETag header
$app->get('/foo', function ($req, $res, $args) {
$resWithEtag = $this['cache']->withEtag($res, 'abc');
$resWithEtag = $this->cache->withEtag($res, 'abc');

return $resWithEtag;
});
Expand Down
14 changes: 1 addition & 13 deletions src/CacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@
namespace Slim\HttpCache;

use InvalidArgumentException;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Psr\Http\Message\ResponseInterface;

class CacheProvider implements ServiceProviderInterface
class CacheProvider
{
/**
* Register this cache provider with a Pimple container
*
* @param Container $container
*/
public function register(Container $container)
{
$container['cache'] = $this;
}

/**
* Enable client-side HTTP caching
*
Expand Down