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