示例#1
0
文件: action.php 项目: kennho/router
 public function __construct($route)
 {
     parent::__construct($route);
     echo 'ENTERED SUBACTION <br/>';
     print_r(parent::get_route()->get_request_path());
     $this->execute_request();
     $this->route_complete();
 }
示例#2
0
文件: index.php 项目: kennho/router
 public function __construct($route)
 {
     parent::__construct($route);
     //check if route is completed, if uncompleted redirect
     $this->route();
     echo 'ENTERED SUBCONTROL <br/>';
     print_r(parent::get_route()->get_request_path());
     $this->execute_request();
     $this->route_complete();
 }
示例#3
0
文件: index.php 项目: kennho/router
 public function delete()
 {
     $route = parent::get_route();
     $accessor = new Accessor($route);
     $accessor->delete_accessor($route->get_request_path(), $route->get_request_params());
 }
示例#4
0
文件: index.php 项目: kennho/router
    $count = strpos($request, '&') == false ? strlen($request) : strpos($request, '&');
    $request = substr($request, 0, $count);
    $request_path = explode("/", $request);
    //extract return type, check if return type is in the allowed list
    $return_type = end($request_path);
    $return_type = set_default($return_type, Constants::get('default_return_type'));
    $return_type = strrchr($return_type, ".");
    $return_type = substr($return_type, 1);
    $allowed_return_types = Constants::get('allowed_return_types');
    if (array_contains($return_type, $allowed_return_types, false) == false) {
        $return_type = Constants::get('default_return_type');
    } else {
        //remove the return type from the request_path
        $item = end($request_path);
        $item = substr($item, 0, strlen($item) - (strlen($return_type) + 1));
        $request_path[count($request_path) - 1] = $item;
    }
    //extract request_method, can be defined in both get and post reauest, post takes precedence
    $request_method = set_default($_REQUEST['request_method'], $_SERVER['REQUEST_METHOD']);
    $allowed_http_methods = Constants::get('allowed_http_methods');
    if (array_contains($request_method, $allowed_http_methods, false) == false) {
        $request_method = Constants::get('default_http_method');
    }
    $request_params = $_REQUEST;
    //form route and send through router
    $route = new Route($request_path, $request_params, $request_method, $return_type);
    $router = new Router($route);
    $router->route();
    //TODO: Can handle redirection to api introduction if no specific request is made
} else {
}