more debug with http.go
parent
6bbb9861ef
commit
25e99fbf93
|
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
@ -8,7 +10,13 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
p := os.Getenv("PORT")
|
p := os.Getenv("PORT")
|
||||||
if err := http.ListenAndServe(":"+p, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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 {
|
})); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue