/** * @param Request $request * @param Response $response */ public function __construct(Request $request, Response $response) { $this->scheme = $request->getScheme(); $this->host = $request->getHost(); $port = $request->getPort(); $this->response = $response; if ('http' === $this->scheme && 80 !== $port) { $this->host .= ':' . $port; } if ('https' === $this->scheme && 443 !== $port) { $this->host .= ':' . $port; } }
public static function getRequestPaths(\Slim\Http\Request $request) { $basePath = $request->getRootUri(); if ($basePath === '' || substr($basePath, -1) != '/') { $basePath .= '/'; } $host = $request->getHost(); $protocol = $request->getScheme(); $requestUri = $request->getRootUri() . $request->getResourceUri(); return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri); }