From ec6f02cfc03813e6feedcd5fa41346228309bd57 Mon Sep 17 00:00:00 2001 From: Andrew Steurer Date: Sun, 18 Aug 2024 02:57:17 -0600 Subject: [PATCH] fixing bug Signed-off-by: Andrew Steurer --- main.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index c364ce1..5f5baf4 100644 --- a/main.go +++ b/main.go @@ -65,25 +65,23 @@ func ping(w http.ResponseWriter, r *http.Request) { // validate checks the flag file's content with the request body to see if they match func validate(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodGet { - bodyBytes, err := io.ReadAll(r.Body) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - defer r.Body.Close() + bodyBytes, err := io.ReadAll(r.Body) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + defer r.Body.Close() - fileBytes, err := os.ReadFile(secretFilePath) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } + fileBytes, err := os.ReadFile(secretFilePath) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } - if string(fileBytes) == string(bodyBytes) { - w.Write([]byte("Success! You found the flag.")) - } else { - w.Write([]byte("The string submitted doesn't match the content of the flag file.")) - } + if string(fileBytes) == string(bodyBytes) { + w.Write([]byte("Success! You found the flag.")) + } else { + w.Write([]byte("The string submitted doesn't match the content of the flag file.")) } }