24 lines
408 B
Go
24 lines
408 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
p := os.Getenv("PORT")
|
|
if err := http.ListenAndServe(":"+p, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
b, _ := io.ReadAll(r.Body)
|
|
log.Printf("> %s (%+v) %s", r.URL, r.Header, b)
|
|
body := os.Getenv("BODY")
|
|
if body == "-" {
|
|
body = string(b)
|
|
}
|
|
w.Write([]byte(body))
|
|
})); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|