commit 6b2d9cacc4876fe1d5d107a37bdc4e099dd80bfe Author: jack77213 Date: Sun Feb 16 15:08:56 2020 +0800 init diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6c58102 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module gitea.hijack.moe/huashui/extproxy + +go 1.13 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go new file mode 100644 index 0000000..0aba4a6 --- /dev/null +++ b/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "bytes" + "io/ioutil" + "net/http" + "os" +) + +func main() { + realServer := os.Getenv("REAL_SERVER") + listenAddress := os.Getenv("LISTEN_ADDR") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.Method == "POST" { + b, _ := ioutil.ReadAll(http.NoBody) + go http.Post(realServer+r.URL.Path, r.Header.Get("Content-Type"), bytes.NewReader(b)) + } + }) + http.ListenAndServe(listenAddress, nil) +}