From 735e7310c904abf18293456d37044dd9c5e796b0 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:12:51 +0530 Subject: feat(api): create a /health API endpoint --- internal/api/health.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 internal/api/health.go (limited to 'internal/api/health.go') diff --git a/internal/api/health.go b/internal/api/health.go new file mode 100644 index 0000000..61d5185 --- /dev/null +++ b/internal/api/health.go @@ -0,0 +1,29 @@ +package api + +import ( + "encoding/json" + "net/http" +) + +type HealthResponse struct { + Status string `json:"status"` +} + +func (s *Server) handleHealth( + w http.ResponseWriter, + r *http.Request, +) { + w.Header().Set("Content-Type", "application/json") + + response := HealthResponse{ + Status: "ok", + } + + if err := json.NewEncoder(w).Encode(response); err != nil { + http.Error( + w, + http.StatusText(http.StatusInternalServerError), + http.StatusInternalServerError, + ) + } +} -- cgit v1.2.3