From f197b125f69f3b2868a9b7f0b53fa4dcb22ce6c6 Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Sat, 10 Jun 2023 22:13:40 +0200 Subject: [PATCH] Allow HTTP::Server::Context#redirect to take an URL --- 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