Fix syntax errors in mock API server Go code

This commit is contained in:
Andreas Düren 2025-03-18 20:36:54 +01:00
parent aefea17f2f
commit 17839a17df

View File

@ -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",