Example #1
0
 /**
  * URL路由检测(根据PATH_INFO)
  * @access public
  * @param  \think\Request $request
  * @param  array          $config
  * @return array
  * @throws \think\Exception
  */
 public static function routeCheck($request, array $config)
 {
     $path = $request->path();
     $depr = $config['pathinfo_depr'];
     $result = false;
     // 路由检测
     $check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on'];
     if ($check) {
         // 开启路由
         if (!empty($config['route'])) {
             // 导入路由配置
             \Norma\Route::import($config['route']);
         }
         // 路由检测(根据路由定义返回不同的URL调度)
         $result = \Norma\Route::check($request, $path, $depr, $config['url_domain_deploy']);
         $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must'];
         if ($must && false === $result) {
             // 路由无效
             throw new \Norma\Exception\HttpException(404, 'Route Not Found');
         }
     }
     if (false === $result) {
         // 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索
         $result = \Norma\Route::parseUrl($path, $depr, $config['controller_auto_search']);
     }
     return $result;
 }