domainService = $domainService; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $apiKey = AuthenticationMiddleware::apiKeyFromRequest($request); if (! $apiKey->hasRole(Role::DOMAIN_SPECIFIC)) { return $handler->handle($request); } $requestMethod = $request->getMethod(); $domainId = Role::domainIdFromMeta($apiKey->getRoleMeta(Role::DOMAIN_SPECIFIC)); $domain = $this->domainService->getDomain($domainId); if ($requestMethod === RequestMethodInterface::METHOD_POST) { $payload = $request->getParsedBody(); $payload[ShortUrlMetaInputFilter::DOMAIN] = $domain->getAuthority(); return $handler->handle($request->withParsedBody($payload)); } return $handler->handle($request->withAttribute(ShortUrlMetaInputFilter::DOMAIN, $domain->getAuthority())); } }