Files
upstream-watermill/_examples/real-world-examples/sending-webhooks/webhooks-server/main.go
2026-09-15 21:27:46 +05:00

31 lines
533 B
Go

package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
// handler receives the webhook requests and logs them in stdout.
func handler(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
fmt.Printf(
"[%s] %s %s: %s\n\n",
time.Now().String(),
r.Method,
r.URL.String(),
string(body),
)
w.WriteHeader(http.StatusOK)
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8001", http.DefaultServeMux)
}