Example #1
0
 /**
  * Create a new named route and handle it with a callback
  * @param string $name Name of the route
  * @param string|Regex|Segment $url The URL to match
  * @param Callable|Controller|Handler $handler One or more callbacks (as additional parameters) to execute to handle this route
  * @return Route The route that is created to handle this request
  */
 public function route($name, $url, $handler)
 {
     $args = func_get_args();
     $name = array_shift($args);
     $url = array_shift($args);
     $route = new Route($url);
     foreach ($args as $arg) {
         $route->add_handler($arg);
     }
     $this->routes[$name] = $route;
     return $route;
 }
Example #2
0
 /**
  * Bind a function to a parsed socket request
  * @param string $name The name of the binding
  * @param string $bind_condition The condition under which to handle this binding
  * @param Callable $handler The callback that will handle this binding
  * @return \Microsite\Route
  */
 public function bind($name, $bind_condition, $handler)
 {
     $args = func_get_args();
     $name = array_shift($args);
     $bind_condition = array_shift($args);
     $route = new Route($bind_condition);
     foreach ($args as $arg) {
         $route->add_handler($arg);
     }
     $this->routes[$name] = $route;
     return $route;
 }