From 216552bc2afd9478e951ff2249ea3108359943f5 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Thu, 22 May 2025 16:23:29 +0100 Subject: [PATCH] Added basic healthcheck --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index e2473bd..bddc4cb 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ const TEMPLATE_FILE = "main.py.tmpl" func main() { http.HandleFunc("/create_model", handleCreateModel) + http.HandleFunc("/health", handleHealthCheck) port := os.Getenv("PORT") if port == "" { @@ -190,3 +191,14 @@ func create_glb(model_code string, filename string) (string, error) { result := buf.String() return result, nil } + +func handleHealthCheck(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return + } + + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(http.StatusOK) + w.Write([]byte("OK")) +}