Use http.Status Close #13

master
kreativmonkey 7 years ago
parent c0765a1e48
commit 8cfebbeebf

@ -24,10 +24,10 @@ func index(w http.ResponseWriter, r *http.Request) {
// Redirect to the URL behind the requested token.
func redirect(w http.ResponseWriter, r *http.Request){
if redirect, ok := short.Redirect(r.URL.Path[1:]); ok{
http.Redirect(w, r, string(redirect), 301)
http.Redirect(w, r, string(redirect), http.StatusMovedPermanently)
fmt.Printf("Token: %s Redirect to: %s \n", string(r.URL.Path[1:]), redirect)
} else {
http.Redirect(w, r, "/", 301)
http.Redirect(w, r, "/", http.StatusMovedPermanently)
}
}

@ -28,7 +28,7 @@ func TestCheckURL(t *testing.T) {
func TestCheckURL2(t *testing.T) {
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Second * 12)
time.Sleep(time.Second * 20)
}))
defer svr.Close()

Loading…
Cancel
Save