- } else if (strcmp($url->path, $this->baseUrl->path)) {
- throw new \http\Controller\Exception(404, "Could not find '$path'");
+ return true;
+ }
+ }
+
+ private function getType($file) {
+ static $inf = null;
+ static $typ = array(".css" => "text/css", ".js" => "applicatin/javascript");
+
+ $ext = strrchr($file, ".");
+ if (isset($typ[$ext])) {
+ return $typ[$ext];
+ }
+
+ if (!$inf) {
+ $inf = new \FINFO(FILEINFO_MIME_TYPE);
+ }
+ return $inf->file($file);
+ }
+
+ private function servePublic(\http\Url $url, \http\Env\Response $res) {
+ $finder = new Finder($this->baseUrl, ROOT."/public");
+ $path = $finder->find($url, "");
+ if ($path->isFile("")) {
+ $res->setHeader("Content-Type", $this->getType($path->getFullPath("")));
+ $res->setBody(new \http\Message\Body(fopen($path->getFullPath(""),"r")));
+ return true;