<?php !defined('APP_DIR') ? die('acceess not defined') : '';
class routerapi{
    public $controller = NULL;
    public $method = NULL;
    static public $_instance = NULL;
    
    static public $ctrl;
    static public $mthd;
    
    /**
     * 路由器初始化
     *
     */
    public function __construct(){
        $a = tool::config('api.router.'.$_REQUEST['method']);
        if ($a) {
        	self::$ctrl = $this->controller = $a['action'];
            self::$mthd = $this->method = $a['method'];
        }else {
            self::$ctrl = $this->controller = 'error';
            self::$mthd = $this->method = 'notFond';
        }
    }
    
    /**
     * 路由器连接
     *
     * @return router
     */
    static public function instance(){
        if (is_null(self::$_instance)) {
            self::$_instance = new routerapi();
            return self::$_instance;
        }else {
            return self::$_instance;
        }
    }
}
?>