コード例 #1
0
 /**
  * Should be run before routes are executed
  * Will abort if etag match is found
  * @param Route $route
  * @param Request $request
  * @param Response|null $response
  * @return Response|null
  * @throws HttpException
  */
 public function before(Route $route, Request $request, $response = null)
 {
     /**
      * TODO implement other Request Methods
      */
     if (!in_array($request->method(), ['GET', 'HEAD'])) {
         return null;
     }
     if ($this->routecache->checkClientHasValidCache()) {
         $response = new Response();
         $response->setNotModified();
         return $response;
     }
     $response = $this->routecache->getResponseFromCache();
     if (empty($response)) {
         $route->after('cache.after');
     }
     return $response;
 }