mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
路由请求类型改为小写
This commit is contained in:
@@ -24,13 +24,13 @@ class Route
|
|||||||
{
|
{
|
||||||
// 路由规则
|
// 路由规则
|
||||||
private static $rules = [
|
private static $rules = [
|
||||||
'GET' => [],
|
'get' => [],
|
||||||
'POST' => [],
|
'post' => [],
|
||||||
'PUT' => [],
|
'put' => [],
|
||||||
'DELETE' => [],
|
'delete' => [],
|
||||||
'PATCH' => [],
|
'patch' => [],
|
||||||
'HEAD' => [],
|
'head' => [],
|
||||||
'OPTIONS' => [],
|
'options' => [],
|
||||||
'*' => [],
|
'*' => [],
|
||||||
'alias' => [],
|
'alias' => [],
|
||||||
'domain' => [],
|
'domain' => [],
|
||||||
@@ -40,21 +40,22 @@ class Route
|
|||||||
|
|
||||||
// REST路由操作方法定义
|
// REST路由操作方法定义
|
||||||
private static $rest = [
|
private static $rest = [
|
||||||
'index' => ['GET', '', 'index'],
|
'index' => ['get', '', 'index'],
|
||||||
'create' => ['GET', '/create', 'create'],
|
'create' => ['get', '/create', 'create'],
|
||||||
'edit' => ['GET', '/:id/edit', 'edit'],
|
'edit' => ['get', '/:id/edit', 'edit'],
|
||||||
'read' => ['GET', '/:id', 'read'],
|
'read' => ['get', '/:id', 'read'],
|
||||||
'save' => ['POST', '', 'save'],
|
'save' => ['post', '', 'save'],
|
||||||
'update' => ['PUT', '/:id', 'update'],
|
'update' => ['put', '/:id', 'update'],
|
||||||
'delete' => ['DELETE', '/:id', 'delete'],
|
'delete' => ['delete', '/:id', 'delete'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// 不同请求类型的方法前缀
|
// 不同请求类型的方法前缀
|
||||||
private static $methodPrefix = [
|
private static $methodPrefix = [
|
||||||
'GET' => 'get',
|
'get' => 'get',
|
||||||
'POST' => 'post',
|
'post' => 'post',
|
||||||
'PUT' => 'put',
|
'put' => 'put',
|
||||||
'DELETE' => 'delete',
|
'delete' => 'delete',
|
||||||
|
'patch' => 'patch',
|
||||||
];
|
];
|
||||||
|
|
||||||
// 子域名
|
// 子域名
|
||||||
@@ -199,7 +200,7 @@ class Route
|
|||||||
unset($rule['__rest__']);
|
unset($rule['__rest__']);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::registerRules($rule, strtoupper($type));
|
self::registerRules($rule, strtolower($type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量注册路由
|
// 批量注册路由
|
||||||
@@ -242,7 +243,7 @@ class Route
|
|||||||
$pattern = array_merge(self::getGroup('pattern'), $pattern);
|
$pattern = array_merge(self::getGroup('pattern'), $pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = strtoupper($type);
|
$type = strtolower($type);
|
||||||
|
|
||||||
if (strpos($type, '|')) {
|
if (strpos($type, '|')) {
|
||||||
$option['method'] = $type;
|
$option['method'] = $type;
|
||||||
@@ -329,7 +330,7 @@ class Route
|
|||||||
}
|
}
|
||||||
if ('*' == $type) {
|
if ('*' == $type) {
|
||||||
// 注册路由快捷方式
|
// 注册路由快捷方式
|
||||||
foreach (['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as $method) {
|
foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) {
|
||||||
if (self::$domain) {
|
if (self::$domain) {
|
||||||
self::$rules['domain'][self::$domain][$method][$rule] = true;
|
self::$rules['domain'][self::$domain][$method][$rule] = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -432,7 +433,7 @@ class Route
|
|||||||
self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern];
|
self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as $method) {
|
foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) {
|
||||||
if (!isset(self::$rules[$method][$name])) {
|
if (!isset(self::$rules[$method][$name])) {
|
||||||
self::$rules[$method][$name] = true;
|
self::$rules[$method][$name] = true;
|
||||||
} elseif (is_array(self::$rules[$method][$name])) {
|
} elseif (is_array(self::$rules[$method][$name])) {
|
||||||
@@ -626,9 +627,9 @@ class Route
|
|||||||
public static function setMethodPrefix($method, $prefix = '')
|
public static function setMethodPrefix($method, $prefix = '')
|
||||||
{
|
{
|
||||||
if (is_array($method)) {
|
if (is_array($method)) {
|
||||||
self::$methodPrefix = array_merge(self::$methodPrefix, array_change_key_case($method, CASE_UPPER));
|
self::$methodPrefix = array_merge(self::$methodPrefix, array_change_key_case($method));
|
||||||
} else {
|
} else {
|
||||||
self::$methodPrefix[strtoupper($method)] = $prefix;
|
self::$methodPrefix[strtolower($method)] = $prefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +700,7 @@ class Route
|
|||||||
* @param string $method 请求类型
|
* @param string $method 请求类型
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function checkDomain($request, &$currentRules, $method = 'GET')
|
public static function checkDomain($request, &$currentRules, $method = 'get')
|
||||||
{
|
{
|
||||||
// 域名规则
|
// 域名规则
|
||||||
$rules = self::$rules['domain'];
|
$rules = self::$rules['domain'];
|
||||||
@@ -809,7 +810,7 @@ class Route
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$method = $request->method();
|
$method = strtolower($request->method());
|
||||||
// 获取当前请求类型的路由规则
|
// 获取当前请求类型的路由规则
|
||||||
$rules = self::$rules[$method];
|
$rules = self::$rules[$method];
|
||||||
// 检测域名部署
|
// 检测域名部署
|
||||||
|
|||||||
Reference in New Issue
Block a user