From f46089e7fccf907efca8c22de4a2352e9bd54751 Mon Sep 17 00:00:00 2001 From: Mikael Johansson Date: Mon, 25 Nov 2024 17:16:54 +0100 Subject: [PATCH] Add even more logging --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 35ee029..d8e3c89 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "encoding/json" "flag" "fmt" + "io" "log" "net/http" "strings" @@ -73,6 +74,15 @@ func imagineHandler(imageName string) http.HandlerFunc { } var admissionReview admission.AdmissionReview + + body, err := io.ReadAll(r.Body) + if err != nil { + log.Printf("Failed to read request body: %v", err) + http.Error(w, "could not read request body", http.StatusBadRequest) + return + } + + log.Printf("Raw JSON request body: %s", string(body)) if err := json.NewDecoder(r.Body).Decode(&admissionReview); err != nil { log.Printf("Failed to decode request body: %v", err) http.Error(w, "could not decode request body", http.StatusBadRequest)