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

Add HTTP::Server::Response#redirect #12526

Conversation

straight-shoota
Copy link
Member

Re-issue of #10412 which was merged in a broken state and subsequently reverted.

This is a proposal for a method HTTP::Server::Response#redirect which offers a simple way to issue redirects from HTTP server handlers. respond_with_status is a similar convenience method.

Redirects are pretty common and a helper for this would be very useful. In fact, there's already an implementation in StaticFileHandler. Most web frameworks probably provide a helper for this, too (example: kemal). But it would be nice to have this at hand for plain server handlers. And simple implementations like kemal's could be based on or replaced by the stdlib implementation.

Resolves #12490

@straight-shoota straight-shoota merged commit 300f748 into crystal-lang:master Oct 23, 2022
@straight-shoota straight-shoota deleted the feature/http-server-redirect2 branch October 23, 2022 16:28
lbguilherme pushed a commit to lbguilherme/crystal that referenced this pull request Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a redirect method to HTTP::Server::Context
2 participants