From cb9adcd188162f1e3c83ff98263d3587b9a2f9ab Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Sun, 24 Sep 2023 08:35:08 +0200 Subject: [PATCH] Allow HTTP::Server::Context#redirect to take an URL (#659) --- src/kemal/ext/context.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kemal/ext/context.cr b/src/kemal/ext/context.cr index 70787b6..d677d08 100644 --- a/src/kemal/ext/context.cr +++ b/src/kemal/ext/context.cr @@ -17,8 +17,8 @@ class HTTP::Server @params ||= Kemal::ParamParser.new(@request, route_lookup.params) end - def redirect(url : String, status_code : Int32 = 302, *, body : String? = nil, close : Bool = true) - @response.headers.add "Location", url + def redirect(url : String | URI, status_code : Int32 = 302, *, body : String? = nil, close : Bool = true) + @response.headers.add "Location", url.to_s @response.status_code = status_code @response.print(body) if body @response.close if close