From 0f13447d8078e1a1f9bb625c34bb4aba9ee51e67 Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <maxadamo@gmail.com> Date: Thu, 1 Sep 2022 00:21:10 +0200 Subject: [PATCH] test --- main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d0d1dd0..2d41f27 100644 --- a/main.go +++ b/main.go @@ -86,16 +86,18 @@ func triggerPuppet(w http.ResponseWriter, req *http.Request) { writeFile(fmt.Sprintf("{\n \"status\": \"KO\",\n \"response\": 401\n \"token\": %v\n}", authToken), "/tmp/503.json") if authToken != bearerToken { statusFile = "/tmp/401.json" - w.WriteHeader(http.StatusUnauthorized) - http.ServeFile(w, req, statusFile) + //w.WriteHeader(http.StatusUnauthorized) + http.Error(w, "unauthorized access", http.StatusUnauthorized) + http.ServeFile(w, req, "/tmp/401.json") + //http.ServeFile(w, req, statusFile) } else { cmd.Run() if verboseBool { InfoLogger.Printf("HTTP Status %v", http.StatusOK) } w.Header().Set("Content-Type", "application/json") + http.ServeFile(w, req, statusFile) } - http.ServeFile(w, req, statusFile) } // function redirect -- GitLab