Example #1
0
 public function renderHeaders()
 {
     $this->headers['Content-type'] = 'application/json';
     $this->headers['Cache-Control'] = 'no-cache, must-revalidate';
     $this->headers['Expires'] = 'Wed, 04 Aug 1982 00:00:00 GMT';
     parent::renderHeaders();
 }
Example #2
0
 public function run()
 {
     try {
         return parent::run();
     } catch (Genghis_HttpException $e) {
         $msg = $e->getMessage() ? $e->getMessage() : Genghis_Response::getStatusText($e->getStatus());
         $response = new Genghis_JsonResponse(array('error' => $msg), $e->getStatus());
         $response->render();
     }
 }
Example #3
0
 public function route($method, $path)
 {
     if ($this->isJsonRequest()) {
         try {
             $api = new Genghis_Api();
             return $api->route($method, $path);
         } catch (Genghis_HttpException $e) {
             $msg = $e->getMessage() ? $e->getMessage() : Genghis_Response::getStatusText($e->getStatus());
             return new Genghis_JsonResponse(array('error' => $msg, 'status' => $e->getStatus()), $e->getStatus());
         }
     } else {
         if (strpos($path, '/assets/') === 0) {
             return $this->getAsset(substr($path, 8));
         } else {
             // not an api request, we'll return index.html and render the page in javascript.
             return $this->renderTemplate('index.html.mustache');
         }
         break;
     }
 }
Example #4
0
 public function __construct($url, $status = 301)
 {
     parent::__construct($url, $status);
 }
Example #5
0
 public function __construct($name, $content, $headers = array())
 {
     parent::__construct($content);
     $this->name = $name;
     $this->headers = array_merge(array('Content-type' => $this->getContentType()), $headers);
 }