@@ -42,8 +42,9 @@ public function __construct(array $params)
4242 protected function routesFromArray (array $ routesGroups )
4343 {
4444 foreach ($ routesGroups as $ key => $ group ) {
45- $ method = isset ($ group [2 ]) ? $ group [2 ] : 'json ' ;
46- $ this ->$ key (key ($ group ), $ group [0 ] . 'Controller ' , $ group [1 ], $ method );
45+ foreach ($ group as $ path => $ item ) {
46+ $ this ->$ key ($ path , $ item [0 ] . 'Controller ' , $ item [1 ]);
47+ }
4748 }
4849 }
4950
@@ -128,10 +129,11 @@ private static final function routeToRegex(string $path): string
128129 * @return array
129130 * @throws \Exception
130131 */
131- private final function getActiveRoute ()
132+ private final function getActiveRoute (): array
132133 {
134+ $ requestPath = str_replace ("? " .$ _SERVER ["QUERY_STRING " ], "" , $ _SERVER ["REQUEST_URI " ]);
133135 foreach ($ this ->routes as $ path => $ route ) {
134- if (preg_match ($ path , $ _SERVER [ " REDIRECT_URL " ] )) {
136+ if (preg_match ($ path , $ requestPath )) {
135137 $ activeRoute = $ route ;
136138 break ;
137139 }
@@ -142,7 +144,7 @@ private final function getActiveRoute()
142144 }
143145
144146 if (!in_array (strtolower ($ _SERVER ["REQUEST_METHOD " ]), $ activeRoute ['method ' ])) {
145- throw new \Exception ("Wrong HTTP method " );
147+ throw new \Exception ("Wrong HTTP method: " . $ activeRoute [ ' method ' ] );
146148 }
147149
148150 return $ activeRoute ;
0 commit comments