This commit is contained in:
jack77213 2020-02-16 15:08:56 +08:00
commit 6b2d9cacc4
Signed by: jack77213
GPG Key ID: CA81AA7BB873B9F1
3 changed files with 23 additions and 0 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module gitea.hijack.moe/huashui/extproxy
go 1.13

0
go.sum Normal file
View File

20
main.go Normal file
View File

@ -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)
}