From fd6bac6da7a7af73cebef6b439acc6e07363dac4 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 20 Sep 2025 23:01:29 +0100 Subject: [PATCH] Return an empty JSON object with a 200 response Signed-off-by: Oliver Davies --- go-api/.envrc | 1 + go-api/main.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 go-api/.envrc create mode 100644 go-api/main.go diff --git a/go-api/.envrc b/go-api/.envrc new file mode 100644 index 0000000..e89fbf9 --- /dev/null +++ b/go-api/.envrc @@ -0,0 +1 @@ +use flake "git+https://code.oliverdavies.uk/opdavies/dev-shells#go" diff --git a/go-api/main.go b/go-api/main.go new file mode 100644 index 0000000..032aa8a --- /dev/null +++ b/go-api/main.go @@ -0,0 +1,22 @@ +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) +}