From 7df7241d0f55cb61cd9fb3a58eeb0c009cab5bfd Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Sun, 20 Sep 2026 22:41:56 +0330 Subject: [PATCH] feat(api): bootstrap Go HTTP server --- backend/cmd/api/main.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 backend/cmd/api/main.go diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go new file mode 100644 index 0000000..986bf88 --- /dev/null +++ b/backend/cmd/api/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "encoding/json" + "log" + "net/http" +) + +func main() { + http.HandleFunc("/health", healthHandler) + + log.Println("server listening on http://localhost:8080") + + if err := http.ListenAndServe(":8080", nil); err != nil { + log.Fatal(err) + } +} + +func healthHandler(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", "application/json") + + response := map[string]string{ + "status": "ok", + } + + if err := json.NewEncoder(w).Encode(response); err != nil { + log.Println("failed to encode health response:", err) + } +}