public function redirectToUri(IHttpResponseMessage $response, $uri, int $statusCode = 302): void
    {
        if (is_string($uri)) {
            $uriString = $uri;
        } elseif ($uri instanceof Uri) {
            $uriString = (string)$uri;
        } else {
            throw new InvalidArgumentException('Uri must be instance of ' . Uri::class . ' or string');
        }

        $response->setStatusCode($statusCode);
        $response->getHeaders()->add('Location', $uriString);
    }