From da8b39ab0d4a49b9c50556d4617ae8993c4a8aac Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <maxadamo@gmail.com> Date: Thu, 1 Sep 2022 00:07:27 +0200 Subject: [PATCH] minor --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5b84317..d0d1dd0 100644 --- a/main.go +++ b/main.go @@ -83,10 +83,11 @@ func triggerPuppet(w http.ResponseWriter, req *http.Request) { authToken := strings.Split(req.Header.Get("Authorization"), "Bearer ")[1] statusFile := "/tmp/200.json" writeFile(fmt.Sprintf("{\n \"status\": \"OK\",\n \"response\": 200\n \"token\": %v\n}", authToken), "/tmp/200.json") - writeFile(fmt.Sprintf("{\n \"status\": \"KO\",\n \"response\": 503\n \"token\": %v\n}", authToken), "/tmp/503.json") + writeFile(fmt.Sprintf("{\n \"status\": \"KO\",\n \"response\": 401\n \"token\": %v\n}", authToken), "/tmp/503.json") if authToken != bearerToken { - statusFile = "/tmp/503.json" - //w.WriteHeader(http.StatusUnauthorized) + statusFile = "/tmp/401.json" + w.WriteHeader(http.StatusUnauthorized) + http.ServeFile(w, req, statusFile) } else { cmd.Run() if verboseBool { -- GitLab