Skip to content

Commit 6f27042

Browse files
committed
added support to catch_all route
1 parent c819574 commit 6f27042

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/Statflo/HTTP/Router.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,26 @@ private function defineRoutes($route, array $configs, BaseApplication $app)
6565

6666
private function defineRoute($route, array $config, BaseApplication $app)
6767
{
68+
$catchAll = strpos($route, '{catch_all}') !== false;
69+
6870
if (substr($route, -1) !== "/") {
69-
$app->{$config['method']}($route . "/", $config['id']);
70-
$app->{$config['method']}($route, $config['id']);
71+
$r1 = $app->{$config['method']}($route . "/", $config['id']);
72+
$r2 = $app->{$config['method']}($route, $config['id']);
73+
74+
if ($catchAll) {
75+
$r1->assert("catch_all", ".*");
76+
$r2->assert("catch_all", ".*");
77+
}
7178

7279
return;
7380
}
7481

75-
$app->{$config['method']}($route, $config['id']);
76-
$app->{$config['method']}(substr($route, -1), $config['id']);
82+
$r1 = $app->{$config['method']}($route, $config['id']);
83+
$r2 = $app->{$config['method']}(substr($route, -1), $config['id']);
84+
85+
if ($catchAll) {
86+
$r1->assert("catch_all", ".*");
87+
$r2->assert("catch_all", ".*");
88+
}
7789
}
7890
}

0 commit comments

Comments
 (0)