Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to set optional response body on redirects #561

Merged
merged 1 commit into from
Apr 4, 2020
Merged

allow to set optional response body on redirects #561

merged 1 commit into from
Apr 4, 2020

Conversation

mamantoha
Copy link
Contributor

Q: HTTP 302 Redirect - is a message-body needed?
A: A body is needed, but it can be empty.

@@ -17,8 +17,9 @@ class HTTP::Server
@params ||= Kemal::ParamParser.new(@request, route_lookup.params)
end

def redirect(url : String, status_code : Int32 = 302)
def redirect(url : String, status_code : Int32 = 302, *, response = "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument should be called body. And maybe nil would be a better default, no need to allocate a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@sdogruyol
Copy link
Member

Thanks @mamantoha 🙏

@sdogruyol sdogruyol merged commit b7506f6 into kemalcr:master Apr 4, 2020
@mamantoha mamantoha deleted the redirect-with-body branch May 15, 2020 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants