feat(api): bootstrap Go HTTP server

This commit is contained in:
2026-09-20 22:41:56 +03:30
parent 14c16faa43
commit 7df7241d0f

34
backend/cmd/api/main.go Normal file
View File

@@ -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)
}
}