Hi everybody,
There is any way to redirect the http request to https? I want redirect all
http://127.0.0.1 to
https://127.0.0.1I've been trying with RedirectHandler(url string, code int) how you can see:
func main() {
authenticator := auth.NewBasicAuthenticator("Train Controler", Secret)
http.HandleFunc("/", authenticator.Wrap(rootHandler))
http.Handle("/socket", websocket.Handler(websocketServer))
err := http.ListenAndServeTLS("127.0.0.1", "./tls/cert.pem", "./tls/key.pem", nil)
err2 := http.ListenAndServe("127.0.0.1", http.RedirectHandler("
https://127.0.0.1", http.StatusFound))
if err != nil || err2 != nil {
log.Fatal(err)
}
}
Thanks a lot for your help, and sorry if it is too easy I am a golang newbie.