mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进Response类的send方法 去除 REQUEST_METHOD IS_GET IS_POST IS_PUT IS_DELETE IS_AJAX __EXT__ 常量 由应用自己定义
This commit is contained in:
@@ -11,6 +11,12 @@
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\Config;
|
||||
use think\Hook;
|
||||
use think\Log;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
|
||||
class Route
|
||||
{
|
||||
// 路由规则
|
||||
@@ -600,7 +606,7 @@ class Route
|
||||
}
|
||||
|
||||
// 获取当前请求类型的路由规则
|
||||
$rules = self::$rules[REQUEST_METHOD];
|
||||
$rules = self::$rules[$request->method()];
|
||||
|
||||
if (!empty(self::$rules['*'])) {
|
||||
// 合并任意请求的路由规则
|
||||
@@ -747,8 +753,8 @@ class Route
|
||||
private static function checkOption($option, $url, $request)
|
||||
{
|
||||
// 请求类型检测
|
||||
if ((isset($option['method']) && false === stripos($option['method'], REQUEST_METHOD))
|
||||
|| (isset($option['ext']) && false === stripos($option['ext'], __EXT__)) // 伪静态后缀检测
|
||||
if ((isset($option['method']) && false === stripos($option['method'], $request->method()))
|
||||
|| (isset($option['ext']) && false === stripos($option['ext'], $request->ext())) // 伪静态后缀检测
|
||||
|| (isset($option['domain']) && !in_array($option['domain'], [$_SERVER['HTTP_HOST'], self::$subDomain])) // 域名检测
|
||||
|| (!empty($option['https']) && !$request->isSsl()) // https检测
|
||||
|| (!empty($option['before_behavior']) && false === Hook::exec($option['before_behavior'], $url)) // 行为检测
|
||||
@@ -915,12 +921,13 @@ class Route
|
||||
$action = array_pop($path);
|
||||
$controller = !empty($path) ? array_pop($path) : null;
|
||||
$module = APP_MULTI_MODULE && !empty($path) ? array_pop($path) : null;
|
||||
$method = Request::instance()->method();
|
||||
// REST 操作方法支持
|
||||
if ('[rest]' == $action) {
|
||||
$action = REQUEST_METHOD;
|
||||
} elseif (Config::get('use_action_prefix') && !empty(self::$methodPrefix[REQUEST_METHOD])) {
|
||||
$action = $method;
|
||||
} elseif (Config::get('use_action_prefix') && !empty(self::$methodPrefix[$method])) {
|
||||
// 操作方法前缀支持
|
||||
$action = 0 !== strpos($action, self::$methodPrefix[REQUEST_METHOD]) ? self::$methodPrefix[REQUEST_METHOD] . $action : $action;
|
||||
$action = 0 !== strpos($action, self::$methodPrefix[$method]) ? self::$methodPrefix[$method] . $action : $action;
|
||||
}
|
||||
}
|
||||
// 封装路由
|
||||
|
||||
Reference in New Issue
Block a user