diff options
author | Stormwind <stormwind@stormwinds-page.de> | 2012-11-30 18:58:32 +0100 |
---|---|---|
committer | Stormwind <stormwind@stormwinds-page.de> | 2012-11-30 18:58:32 +0100 |
commit | facd4f143bb3f0bb44d89b6ff11e61a0b7c36427 (patch) | |
tree | 06974380eb50c3ad5cee8bbe17247d160e94fd1f /lib | |
parent | d28dc720d10a3380b5649e29db053ca9a989efd5 (diff) |
Add redirect to response
Now a relocation can be done, by calling redirect with the URL you want
relocate to.
This will set the Location header and set the status code to 302.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zero/response.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/zero/response.rb b/lib/zero/response.rb index 24c1aaf..a3e1651 100644 --- a/lib/zero/response.rb +++ b/lib/zero/response.rb @@ -67,5 +67,14 @@ module Zero self.header['Content-Type'] = value end + # Sets the Location header to the given URL and the status code to 302. + # + # @param [String] location Redirect URL + # + def redirect(location) + self.status = 302 + self.header['Location'] = location + end + end end |