Skip to content

Commit 40c884e

Browse files
committed
default routes
1 parent fe95ea5 commit 40c884e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Web/Router.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class Router implements RouterInterface
2121
public function __construct()
2222
{
2323
$this->defaultNamespaceName = "App\\Controllers\\";
24+
25+
// default routes
26+
$this->map('/', [], '*');
2427
}
2528

2629
/**
@@ -136,10 +139,6 @@ public function dispatch($uri = null)
136139
protected function createDispatcher()
137140
{
138141
return $this->dispatcher ?: \FastRoute\simpleDispatcher(function (\FastRoute\RouteCollector $r) {
139-
// 默认路由
140-
if (!isset($this->routes['/'])) {
141-
$this->map('/', [], '*');
142-
}
143142
foreach ($this->routes as $pattern => $route) {
144143
$r->addRoute($route['methods'], $pattern, $route['handler']);
145144
}

0 commit comments

Comments
 (0)