-
- 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;
- }
+
+ /**
+ * Redirect to canononical url
+ * @param string $cnn
+ */
+ private function serveCanonical($cnn) {
+ $this->response->setHeader("Location", $this->baseUrl->mod(["path" => $cnn]));
+ $this->response->setResponseCode(301);
+ $this->response->send();
+ }
+
+ /**
+ * Serve index.css
+ */
+ private function serveStylesheet() {
+ $this->response->setHeader("Content-Type", "text/css");
+ $this->response->setBody(new \http\Message\Body(fopen(ROOT."/public/index.css", "r")));
+ $this->response->send();
+ }
+
+ /**
+ * Serve index.js
+ */
+ private function serveJavascript() {
+ $this->response->setHeader("Content-Type", "application/javascript");
+ $this->response->setBody(new \http\Message\Body(fopen(ROOT."/public/index.js", "r")));
+ $this->response->send();