// required for Expires, Minify //$app->pipe(Middleware::Expires()); //$app->pipe(Middleware::Minify()); $app->pipe(Middleware::BlockSpam()); //$app->pipe(Middleware::PhpSession()->name('DetectorSessionId')); //$app->pipe(Middleware::Geolocate()->saveInSession(true)); //$app->pipe(Middleware::Cache($pool)); $app->pipe(Middleware::responseTime()); $app->pipeRoutingMiddleware(); $app->pipeDispatchMiddleware(); $cache = new File(array(File::DIR => 'cache/')); $app->get('/js/features.js', function (RequestInterface $request, ResponseInterface $response, callable $next) use($errorLog, $cache) { $response->withAddedHeader('content-type', 'application/x-javascript'); $response->getBody()->write(Modernizr::buildJs()); $detector = new Detector($cache, $errorLog); $cookieID = $detector->getCookieId($_SERVER); $response->getBody()->write(Modernizr::buildConvertJs($cookieID, '', false)); return $response; }); $app->get('/', function (RequestInterface $request, ResponseInterface $response, callable $next) use($errorLog, $cache) { $detector = new Detector($cache, $errorLog); // if this is a request from features.js.php don't run the build function $ua = $detector->build($_SERVER); /* if (null === $ua) { $html = '<html><head><script type="text/javascript">'; $html .= Modernizr::buildJs(); $html .= Modernizr::buildConvertJs($detector->getCookieId($_SERVER), '', true); $html .= '</script></head><body></body></html>';