あるサービスの webhook の中身をみたいことがあったのでメモ
compose.yml
services:
server:
image: golang:1.26
working_dir: /app
volumes:
- .:/app
command: go run main.go
ports:
- "3000:3000"
client:
image: node:24
command: sh -c "npm install -g smee-client && smee --url ${SMEE_URL} --target http://server:3000/webhook"
environment:
- SMEE_URL=${SMEE_URL}
depends_on:
- server
main.go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
http.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
//fmt.Println("===== Headers =====")
//for k, v := range r.Header {
// fmt.Printf("%s: %v\n", k, v)
//}
//fmt.Println("===== Body =====")
fmt.Println(string(body))
w.WriteHeader(http.StatusOK)
})
log.Println("listening on :3000")
log.Fatal(http.ListenAndServe(":3000", nil))
}
使い方
SMEE_URL=https://smee.io/xxxx docker compose up 2>&1 | tee webhook.log