コード例 #1
0
ファイル: Route.php プロジェクト: neroreflex/gishiki
 /**
  * Add a route to the route redirection list.
  * 
  * @param Route $route the route to be added
  *
  * @return Route the added route
  */
 public static function &addRoute(Route &$route)
 {
     //add the given route to the routes list
     $route->isSpecialCallback() === false ? self::$routes[] =& $route : (self::$callbacks[] =& $route);
     return $route;
 }
コード例 #2
0
ファイル: Environment.php プロジェクト: neroreflex/gishiki
 /**
  * Fullfill the request made by the client.
  */
 public function FulfillRequest()
 {
     //get current request...
     $currentRequest = Request::createFromEnvironment(self::$currentEnvironment);
     //...and serve it
     $response = new Response();
     try {
         //trigger the exception if data is malformed!
         $currentRequest->getDeserializedBody();
         //include the list of routes (if it exists)
         if (file_exists(APPLICATION_DIR . 'routes.php')) {
             include APPLICATION_DIR . 'routes.php';
         }
         //...and serve it
         $response = Route::run($currentRequest);
     } catch (\RuntimeException $ex) {
         $response = $response->withStatus(400);
         $response = $response->write($ex->getMessage());
     }
     //send response to the client
     $response->send();
 }