gokrazy/httpsredirect.go
Janis Streib 17bec15432
Added proof of concept TLS support (#7) (#53)
If there is a certificate and key in /etc/ssl/gokrazy-web.{pem,key.pem},
the webinterface will serve and redirect to https.
2020-05-31 21:58:03 +02:00

11 lines
253 B
Go

package gokrazy
import "net/http"
// TODO: Configurable https-port
func httpsRedirect(w http.ResponseWriter, r *http.Request) {
r.URL.Host = r.Host
r.URL.Scheme = "https"
http.Redirect(w, r, r.URL.String(), http.StatusFound) // Redirect to https
}