I would like to do this in go and was wondering if my approach is good enough or if there is a better way. Below is the example code and a playground link https://play.golang.org/p/wLzmOFMrudP
Andrew const ( domain = "example.com" wwwdomain = "www." + domain ) mux := http.NewServeMux() mux.HandleFunc(domain+"/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Connection", "close") url := "http://" + wwwdomain + r.URL.String() http.Redirect(w, r, url, http.StatusMovedPermanently) }) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello, world")) }) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.