extproxy/main.go

21 lines
437 B
Go

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