/**
  * @param string $request Request uri
  * @throws \RuntimeException
  * @return \Zend\Http\PhpEnvironment\Response
  */
 public function dispatch($request)
 {
     if (!$this->getResolver()) {
         throw new \RuntimeException("No resolver setted");
     }
     $asset = $this->resolver->resolve($request);
     $content = null;
     $responseCode = 404;
     $headers = Headers::fromString("Content-Type: text/plain");
     if ($asset) {
         $headers = $this->getHeaders($asset->getFile(), $asset->getMime());
         if ($this->browserCached($asset->getFile())) {
             $responseCode = 304;
             $headers->addHeader(Connection::fromString("Connection: close"));
         } else {
             $responseCode = 200;
             $cacheKey = "assets-cache-" . md5($request);
             if ($this->cache) {
                 $content = $this->cache->getItem($cacheKey);
             }
             if (!$content) {
                 $content = $asset->getContent();
                 $assetName = end(explode('\\', get_class($asset)));
                 if (array_key_exists($assetName, $this->filters)) {
                     foreach ($this->filters[$assetName] as $filter) {
                         $content = $filter->filter($content);
                     }
                 }
                 if ($this->cache) {
                     $this->cache->addItem($cacheKey, $content);
                 }
             }
         }
     } else {
         $content = "Asset not found!";
     }
     $response = new Response();
     $response->setStatusCode($responseCode);
     $response->setContent($content);
     $response->setHeaders($headers);
     return $response;
 }