From 3d2cb71808d50cb865625e400e040a313593b746 Mon Sep 17 00:00:00 2001 From: Valentin Date: Mon, 5 Aug 2024 15:03:43 +0200 Subject: [PATCH] feat(sources) uploading sources --- .gitattributes | 1 + .gitignore | 2 ++ src/go.mod | 3 +++ src/main.go | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 .gitattributes create mode 100644 src/go.mod create mode 100644 src/main.go diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fa1385d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/.gitignore b/.gitignore index 6f72f89..c3a5712 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ go.work.sum # env file .env + +build/* diff --git a/src/go.mod b/src/go.mod new file mode 100644 index 0000000..e990ff1 --- /dev/null +++ b/src/go.mod @@ -0,0 +1,3 @@ +module itsmrval/http-to-https + +go 1.22.5 diff --git a/src/main.go b/src/main.go new file mode 100644 index 0000000..4d9ea8b --- /dev/null +++ b/src/main.go @@ -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) + } +}