Skip to content

Commit

Permalink
Allow HTTP::Server::Context#redirect to take an URL (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
xendk committed Sep 24, 2023
1 parent a939a57 commit cb9adcd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/kemal/ext/context.cr
Expand Up @@ -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
Expand Down

0 comments on commit cb9adcd

Please sign in to comment.