minor changes
This commit is contained in:
1
Frontend
1
Frontend
Submodule Frontend deleted from 0d629d1da2
@@ -28,10 +28,25 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register handlers with logging middleware
|
// Create a middleware for CORS
|
||||||
http.HandleFunc("/submit", loggingMiddleware(h.SubmitHandler))
|
corsMiddleware := func(next http.HandlerFunc) http.HandlerFunc {
|
||||||
http.HandleFunc("/status", loggingMiddleware(h.StatusHandler))
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.HandleFunc("/result", loggingMiddleware(h.ResultHandler))
|
// Set CORS headers
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:5173")
|
||||||
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||||
|
if r.Method == http.MethodOptions {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
next(w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register handlers with logging and CORS middleware
|
||||||
|
http.HandleFunc("/submit", corsMiddleware(loggingMiddleware(h.SubmitHandler)))
|
||||||
|
http.HandleFunc("/status", corsMiddleware(loggingMiddleware(h.StatusHandler)))
|
||||||
|
http.HandleFunc("/result", corsMiddleware(loggingMiddleware(h.ResultHandler)))
|
||||||
|
|
||||||
port := ":8080"
|
port := ":8080"
|
||||||
log.Printf("Server started at %s", port)
|
log.Printf("Server started at %s", port)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user