-
-
Save ii0/751697b29b750d6fafb1df8e23bbd430 to your computer and use it in GitHub Desktop.
Http Redirect in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func redirect(w http.ResponseWriter, r *http.Request) { | |
http.Redirect(w, r, "http://www.google.com", 301) | |
} | |
func main() { | |
http.HandleFunc("/", redirect) | |
err := http.ListenAndServe(":9090", nil) | |
if err != nil { | |
log.Fatal("ListenAndServe: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment