diff --git a/Slim/Interfaces/RouteCollectorProxyInterface.php b/Slim/Interfaces/RouteCollectorProxyInterface.php index 1c49bb228..228700d3b 100644 --- a/Slim/Interfaces/RouteCollectorProxyInterface.php +++ b/Slim/Interfaces/RouteCollectorProxyInterface.php @@ -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; } diff --git a/Slim/Routing/RouteCollectorProxy.php b/Slim/Routing/RouteCollectorProxy.php index a946d148f..f3ad07dfa 100644 --- a/Slim/Routing/RouteCollectorProxy.php +++ b/Slim/Routing/RouteCollectorProxy.php @@ -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; @@ -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); } }