Skip to content

Commit

Permalink
fix route match hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
millken committed Sep 19, 2018
1 parent ff9a528 commit 9cb67f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/Route/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9cb67f4

Please sign in to comment.