Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Slim/Interfaces/RouteCollectorProxyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ public function group(string $pattern, $callable): RouteGroupInterface;
/**
* Add a route that sends an HTTP redirect
*
* @param string|UriInterface $to
* @param string $from The route URI pattern
* @param string|UriInterface $to The redirect URI
* @param int $status The HTTP status code
* @param string[] $methods Numeric array of HTTP methods
*/
public function redirect(string $from, $to, int $status = 302): RouteInterface;
public function redirect(string $from, $to, int $status = 302, array $methods = ['GET']): RouteInterface;
}
4 changes: 2 additions & 2 deletions Slim/Routing/RouteCollectorProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function group(string $pattern, $callable): RouteGroupInterface
/**
* {@inheritdoc}
*/
public function redirect(string $from, $to, int $status = 302): RouteInterface
public function redirect(string $from, $to, int $status = 302, array $methods = ['GET']): RouteInterface
{
$responseFactory = $this->responseFactory;

Expand All @@ -191,6 +191,6 @@ public function redirect(string $from, $to, int $status = 302): RouteInterface
return $response->withHeader('Location', (string) $to);
};

return $this->get($from, $handler);
return $this->map($methods, $from, $handler);
}
}