parent
e70e069662
commit
3d2cb71808
|
|
@ -0,0 +1 @@
|
||||||
|
* -text
|
||||||
|
|
@ -23,3 +23,5 @@ go.work.sum
|
||||||
|
|
||||||
# env file
|
# env file
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
build/*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
module itsmrval/http-to-https
|
||||||
|
|
||||||
|
go 1.22.5
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
targetURL := "https://" + r.Host + r.RequestURI
|
||||||
|
http.Redirect(w, r, targetURL, http.StatusMovedPermanently)
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Println("Service running on :80")
|
||||||
|
if err := http.ListenAndServe(":80", nil); err != nil {
|
||||||
|
log.Fatalf("%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue