diff --git a/src/http-server/src/Server.php b/src/http-server/src/Server.php index ddcdaee35..d4d1d1488 100644 --- a/src/http-server/src/Server.php +++ b/src/http-server/src/Server.php @@ -119,4 +119,18 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface Context::set(ResponseInterface::class, $psr7Response = new Psr7Response($response)); return [$psr7Request, $psr7Response]; } + + public function getServerName(): string + { + return $this->serverName; + } + + /** + * @return $this + */ + public function setServerName(string $serverName) + { + $this->serverName = $serverName; + return $this; + } } diff --git a/src/server/src/Server.php b/src/server/src/Server.php index 8a9f73746..953965aa9 100644 --- a/src/server/src/Server.php +++ b/src/server/src/Server.php @@ -187,6 +187,10 @@ class Server implements ServerInterface $this->onRequestCallbacks[$className] = $serverName; $class = $this->container->get($className); + if (method_exists($class, 'setServerName')) { + // Override the server name. + $class->setServerName($serverName); + } if ($class instanceof MiddlewareInitializerInterface) { $class->initCoreMiddleware($serverName); }