Skip to content

Commit

Permalink
Fixed the redirect method.
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Parker <joshua@joshuaparker.dev>
  • Loading branch information
nomadicjosh committed Sep 4, 2024
1 parent 5528aa0 commit 45642b5
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions Http/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Codefy\Framework\Contracts\RoutingController;
use Psr\Http\Message\ResponseInterface;
use Qubus\Http\Factories\RedirectResponseFactory;
use Qubus\Http\Session\SessionService;
use Qubus\Routing\Controller\Controller;
use Qubus\Routing\Router;
Expand Down Expand Up @@ -56,16 +57,6 @@ public function setView(Renderer $view): self
*/
public function redirect(string $url, int $status = 302): ?ResponseInterface
{
if ($status) {
$this->response = $this->response->withStatus($status);
}

$response = $this->response;

if (!$response->getHeaderLine('Location')) {
$response = $response->withHeader('Location', $url);
}

return $this->response = $response;
return RedirectResponseFactory::create(uri: $url, status: $status);
}
}

0 comments on commit 45642b5

Please sign in to comment.