From 9cb67f441b15f54d3096026e80ca703fa27e326a Mon Sep 17 00:00:00 2001 From: millken Date: Thu, 20 Sep 2018 03:32:44 +0800 Subject: [PATCH] fix route match hostname --- src/Dispatcher.php | 2 +- src/Route/Route.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Dispatcher.php b/src/Dispatcher.php index 40da8a5..dc1df6d 100644 --- a/src/Dispatcher.php +++ b/src/Dispatcher.php @@ -28,7 +28,7 @@ public function __construct(iterable $middleware) public function dispatch(ServerRequestInterface $request): ResponseInterface { - return $this->handle($request); + return $this->handle($request)->withHeader('server', 'YPF-'.Application::VERSION); } public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Route/Route.php b/src/Route/Route.php index b5b5c01..433a5d9 100644 --- a/src/Route/Route.php +++ b/src/Route/Route.php @@ -118,6 +118,12 @@ public function hasMethod(string $method): bool public function isMatch(ServerRequestInterface $request): bool { $path = $request->getUri()->getPath(); + //match hostname + if ($this->host) { + if ($request->getUri()->getHost() !== strtolower($this->host)) { + return false; + } + } if ($this->isStaticRoute()) { return $this->getPath() == $path; } else {