From 17839a17dfa22c0713c4d4ea4585d47fc5b2c984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20D=C3=BCren?= Date: Tue, 18 Mar 2025 20:36:54 +0100 Subject: [PATCH] Fix syntax errors in mock API server Go code --- start.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/start.sh b/start.sh index da51238..b3d31e8 100644 --- a/start.sh +++ b/start.sh @@ -679,9 +679,10 @@ func main() { // Map to store verification codes verificationCodes := make(map[string]string) + // Mock API server for main application http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"ok","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339)) + fmt.Fprintf(w, `{"status":"ok","version":"mock-1.0.0","time":"%s"}`, time.Now().Format(time.RFC3339)) }) // Handle OTT (One-Time Token) requests - this is the SPECIFIC endpoint the Ente client uses @@ -789,7 +790,7 @@ func main() { } else { // Just handle other methods with a generic response w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"mock","endpoint":"%s","method":"%s"}\`, r.URL.Path, r.Method) + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) } }) @@ -897,7 +898,7 @@ func main() { } else { // Handle other methods with a generic response w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"mock","endpoint":"%s","method":"%s"}\`, r.URL.Path, r.Method) + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) } }) @@ -1003,9 +1004,10 @@ func main() { // Map to store verification codes verificationCodes := make(map[string]string) + // Mock API server for main application http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"ok","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339)) + fmt.Fprintf(w, `{"status":"ok","version":"mock-1.0.0","time":"%s"}`, time.Now().Format(time.RFC3339)) }) // Handle registration requests @@ -1057,7 +1059,7 @@ func main() { } else { // Just handle other methods with a generic response w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"mock","endpoint":"%s","method":"%s"}\`, r.URL.Path, r.Method) + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) } }) @@ -1165,7 +1167,7 @@ func main() { } else { // Handle other methods with a generic response w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, \`{"status":"mock","endpoint":"%s","method":"%s"}\`, r.URL.Path, r.Method) + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) } }) @@ -1310,6 +1312,7 @@ func main() { } logger := log.New(multiWriter, "", log.LstdFlags) + // Mock API server for public albums http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -1323,6 +1326,10 @@ func main() { json.NewEncoder(w).Encode(response) }) + // Just handle other methods with a generic response + w.Header().Set("Content-Type", "application/json") + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { logger.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method) @@ -1336,9 +1343,6 @@ func main() { w.Header().Set("Content-Type", "application/json") - // Use fmt.Fprintf to explicitly use the fmt package - fmt.Fprintf(w, "{\"status\":\"processing\"}") - // Use json package to create the response response := map[string]string{ "status": "mock", @@ -1420,6 +1424,7 @@ func main() { } logger := log.New(multiWriter, "", log.LstdFlags) + // Mock API server for public albums http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -1433,6 +1438,10 @@ func main() { json.NewEncoder(w).Encode(response) }) + // Just handle other methods with a generic response + w.Header().Set("Content-Type", "application/json") + fmt.Fprintf(w, `{"status":"mock","endpoint":"%s","method":"%s"}`, r.URL.Path, r.Method) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { logger.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method) @@ -1446,9 +1455,6 @@ func main() { w.Header().Set("Content-Type", "application/json") - // Use fmt.Fprintf to explicitly use the fmt package - fmt.Fprintf(w, "{\"status\":\"processing\"}") - // Use json package to create the response response := map[string]string{ "status": "mock",