Skip to content

Commit 26007d8

Browse files
Dean KarnDean Karn
authored andcommitted
update redirect on non GET methods to 308
- hadn't realized is was added to the http package, wasn't in previous releases.
1 parent ba12479 commit 26007d8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func (p *Mux) redirect(method string, to string) (h http.HandlerFunc) {
509509
code := http.StatusMovedPermanently
510510

511511
if method != http.MethodGet {
512-
code = http.StatusTemporaryRedirect
512+
code = http.StatusPermanentRedirect
513513
}
514514

515515
h = func(w http.ResponseWriter, r *http.Request) {

pure_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestAllMethods(t *testing.T) {
183183
path: "/redirect",
184184
url: "/redirect/",
185185
handler: defaultHandler,
186-
code: http.StatusTemporaryRedirect,
186+
code: http.StatusPermanentRedirect,
187187
body: "",
188188
},
189189
}
@@ -467,7 +467,7 @@ func TestRedirect(t *testing.T) {
467467
Equal(t, code, http.StatusMovedPermanently)
468468

469469
code, _ = request(http.MethodPost, "/home", p)
470-
Equal(t, code, http.StatusTemporaryRedirect)
470+
Equal(t, code, http.StatusPermanentRedirect)
471471

472472
p.SetRedirectTrailingSlash(false)
473473

0 commit comments

Comments
 (0)