@@ -37,7 +37,7 @@ public static function exists(): bool {
37
37
protected ?int $ version ;
38
38
protected ?\Swoole \Http \Request $ request ;
39
39
protected function __construct (string $ uri , string $ method , ?int $ version ) {
40
- $ action = explode ('/ ' , strtolower ( $ uri) );
40
+ $ action = explode ('/ ' , $ uri );
41
41
array_shift ($ action );
42
42
if ('' === end ($ action )) {
43
43
array_pop ($ action );
@@ -64,7 +64,7 @@ public function getControllerName(): string {
64
64
return $ this ->controller_name ;
65
65
}
66
66
public function isWebhook (): bool {
67
- $ action1 = reset ($ this ->action );
67
+ $ action1 = strtolower ( reset ($ this ->action ) );
68
68
return 'webhook ' === $ action1 || 'server ' === $ action1 || 'service ' === $ action1 ;
69
69
}
70
70
public function getHost (): string {
@@ -92,7 +92,7 @@ public function getController(\Swoole\Http\Response $response): Controller {
92
92
$ par = [];
93
93
$ action = $ this ->action ;
94
94
do {
95
- $ controller_name = '/ ' . implode ('/ ' , $ action );
95
+ $ controller_name = '/ ' . strtolower ( implode ('/ ' , $ action) );
96
96
$ cache_key = self ::getCacheKey ($ controller_name , $ this ->method , $ this ->version , count ($ par ));
97
97
if (array_key_exists ($ cache_key , self ::$ cache )) {
98
98
$ classname = self ::$ cache [$ cache_key ];
@@ -113,31 +113,24 @@ public function getController(\Swoole\Http\Response $response): Controller {
113
113
$ par [] = array_pop ($ action );
114
114
continue ;
115
115
}
116
- $ tmp = $ action ;
117
- $ tmp [] = $ this ->method . $ v ;
118
- $ classname = '\\Controller \\' . implode ('\\' , $ tmp );
116
+ $ classname = '\\Controller \\' . strtolower (implode ('\\' , $ action )) . '\\' . $ this ->method . $ v ;
119
117
$ class_exists = class_exists ($ classname , false );
120
118
if (! $ class_exists ) {
121
- $ file_name = Environment::getDir ()->controller . implode ('/ ' , $ tmp ) . '.php ' ;
119
+ $ file_name = Environment::getDir ()->controller . strtolower (implode ('/ ' , $ action )) . '/ ' .
120
+ $ this ->method . $ v . '.php ' ;
122
121
if (file_exists ($ file_name )) {
123
122
require_once $ file_name ;
124
123
$ class_exists = class_exists ($ classname , false );
125
124
}
126
125
}
127
- if (! $ class_exists ) {
128
- if (empty ($ action )) {
129
- break ;
130
- }
131
- $ par [] = array_pop ($ action );
132
- continue ;
133
- } elseif ((! empty ($ par ) && ! $ classname ::WITH_PAR )) {
126
+ if ((! $ class_exists ) || (! empty ($ par ) && ! $ classname ::WITH_PAR )) {
134
127
if (empty ($ action )) {
135
128
break ;
136
129
}
137
130
$ par [] = array_pop ($ action );
138
131
continue ;
139
132
}
140
- $ controller_name = '/ ' . implode ('/ ' , $ action );
133
+ $ controller_name = '/ ' . strtolower ( implode ('/ ' , $ action) );
141
134
$ this ->controller_name = $ controller_name ;
142
135
if ($ classname ::USE_ROUTER_CACHE ) {
143
136
$ cache_key = self ::getCacheKey ($ controller_name , $ this ->method , $ this ->version , count ($ par ));
0 commit comments