chore: use http.Status* instead of hard code (#1482)
This commit is contained in:
@ -16,6 +16,8 @@ type Redirect struct {
|
||||
}
|
||||
|
||||
func (r Redirect) Render(w http.ResponseWriter) error {
|
||||
// todo(thinkerou): go1.6 not support StatusPermanentRedirect(308)
|
||||
// when we upgrade go version we can use http.StatusPermanentRedirect
|
||||
if (r.Code < 300 || r.Code > 308) && r.Code != 201 {
|
||||
panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ func TestRenderRedirect(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
data1 := Redirect{
|
||||
Code: 301,
|
||||
Code: http.StatusMovedPermanently,
|
||||
Request: req,
|
||||
Location: "/new/location",
|
||||
}
|
||||
@ -296,7 +296,7 @@ func TestRenderRedirect(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
data2 := Redirect{
|
||||
Code: 200,
|
||||
Code: http.StatusOK,
|
||||
Request: req,
|
||||
Location: "/new/location",
|
||||
}
|
||||
|
Reference in New Issue
Block a user