Пример #1
0
function map_request_to_handler($req, $routes)
{
    if ($route = route_match($routes, $req)) {
        $req['path'] = $route['path_matches'];
        exit_with_mojo_flush_response($req, next_func($req, $route['funcs']));
    }
    exit_with_404_plain('Not Found');
}
Пример #2
0
function next_handler()
{
    $args = func_get_args();
    if (empty($args)) {
        $args = array(request_());
    }
    $matches = array();
    $handler = next_handler_match_($args[0], $matches);
    if (!is_null($handler)) {
        if (is_callable($handler['func'])) {
            $response = call_user_func_array($handler['func'], array_merge(array($args, $matches)));
        } else {
            trigger_error_("Invalid handler func", E_USER_ERROR);
        }
        return $response;
    }
    //TODO: this should be overridable by the user
    exit_with_404_plain('Not Found');
}