Skip to content

Commit be1b15c

Browse files
committed
typo bruh
Signed-off-by: slashexx <dhruvpuri.35@gmail.com>
1 parent 96d6b95 commit be1b15c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

backend/api-gateway/main.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"log"
88
"net/http"
9+
"io/ioutil"
910
)
1011

1112
type CodeRequest struct {
@@ -35,24 +36,32 @@ func executeCode(w http.ResponseWriter, r *http.Request) {
3536
return
3637
}
3738

39+
log.Printf("Request body: %+v", req)
3840

3941
reqBody, err := json.Marshal(req)
4042
if err != nil {
4143
log.Printf("Error marshaling request: %v", err)
4244
http.Error(w, "Failed to marshal request", http.StatusInternalServerError)
4345
return
4446
}
45-
// https://codebrewery-code-execution-service.onrender.com
46-
resp, err := http.Post("https://codebrewery-code-execution-service.onrender.com", "application/json", bytes.NewBuffer(reqBody))
47+
48+
url := "https://codebrewery-code-execution-service.onrender.com"
49+
log.Printf("Sending request to Code Execution Service: %s", url)
50+
51+
resp, err := http.Post(url, "application/json", bytes.NewBuffer(reqBody))
4752
if err != nil {
4853
log.Printf("Error contacting code execution service: %v", err)
4954
http.Error(w, "Failed to execute code", http.StatusInternalServerError)
5055
return
5156
}
5257
defer resp.Body.Close()
5358

59+
log.Printf("Received response status: %d", resp.StatusCode)
60+
5461
if resp.StatusCode != http.StatusOK {
5562
log.Printf("Code execution service returned status: %d", resp.StatusCode)
63+
responseBody, _ := ioutil.ReadAll(resp.Body)
64+
log.Printf("Response body: %s", string(responseBody))
5665
http.Error(w, "Code execution service returned an error", http.StatusInternalServerError)
5766
return
5867
}

0 commit comments

Comments
 (0)