route() public method

Routes the current request.
public route ( flight\net\Request $request ) : Route | boolean
$request flight\net\Request Request object
return Route | boolean Matching route or false if no match
示例#1
0
 function check($str = '')
 {
     $route = $this->router->route($this->request);
     $params = array_values($route->params);
     $this->assertTrue(is_callable($route->callback));
     call_user_func_array($route->callback, $params);
     $this->expectOutputString($str);
 }
示例#2
0
 function routeRequest()
 {
     $dispatched = false;
     while ($route = $this->router->route($this->request)) {
         $params = array_values($route->params);
         $continue = $this->dispatcher->execute($route->callback, $params);
         $dispatched = true;
         if (!$continue) {
             break;
         }
         $this->router->next();
         $dispatched = false;
     }
     if (!$dispatched) {
         echo '404';
     }
 }