lab/go-api/main.go
Oliver Davies fd6bac6da7 Return an empty JSON object with a 200 response
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
2025-09-20 23:16:29 +01:00

22 lines
367 B
Go

package main
import (
"encoding/json"
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Running handler...")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]any{})
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}