refactor: extract exception and cache middleware (#4248)

This commit is contained in:
Dag 2024-09-01 21:48:14 +02:00 committed by GitHub
parent 36fd72c87e
commit a6bdc322b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 99 additions and 56 deletions

View file

@ -56,22 +56,14 @@ $container['logger'] = function () {
// $logger->addHandler(new StreamHandler('/tmp/rss-bridge.txt', Logger::INFO));
// Uncomment this for debug logging to fs
//$logger->addHandler(new StreamHandler('/tmp/rss-bridge-debug.txt', Logger::DEBUG));
// $logger->addHandler(new StreamHandler('/tmp/rss-bridge-debug.txt', Logger::DEBUG));
return $logger;
};
$container['cache'] = function ($c) {
/** @var CacheFactory $cacheFactory */
$cacheFactory = $c['cache_factory'];
$type = Configuration::getConfig('cache', 'type');
if (!$type) {
throw new \Exception('No cache type configured');
}
if (Debug::isEnabled()) {
$cache = $cacheFactory->create('array');
} else {
$cache = $cacheFactory->create($type);
}
$cache = $cacheFactory->create(Configuration::getConfig('cache', 'type'));
return $cache;
};