more debug with http.go

master
bel 2023-03-25 22:18:24 -06:00
parent 6bbb9861ef
commit 25e99fbf93
1 changed files with 9 additions and 1 deletions

10
src/testdata/http.go vendored
View File

@ -1,6 +1,8 @@
package main
import (
"io"
"log"
"net/http"
"os"
)
@ -8,7 +10,13 @@ import (
func main() {
p := os.Getenv("PORT")
if err := http.ListenAndServe(":"+p, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(os.Getenv("BODY")))
b, _ := io.ReadAll(r.Body)
log.Printf("> %s", b)
body := os.Getenv("BODY")
if body == "-" {
body = string(b)
}
w.Write([]byte(body))
})); err != nil {
panic(err)
}