Use 302 to redirect instead of 301

`301` means "Moved Permanently", so browser caches this redirect, it is used when changing server URL.
`302` means "Found", it is used generally (e.g. redirect top page after
login).

Each of `301`, `302`, `303` and `307` means redict, but they are
different. We could choice those status in case.
This commit is contained in:
TSUYUSATO Kitsune 2016-02-10 00:25:01 +09:00
parent 9aa0819f29
commit 55361b3c9a
2 changed files with 3 additions and 3 deletions

View file

@ -8,9 +8,9 @@ class HTTP::Server
Kemal::ParamParser.new(@route, @request).parse
end
def redirect(url)
def redirect(url, status_code = 302)
@response.headers.add "Location", url
@response.status_code = 301
@response.status_code = status_code
end
end
end