Return an empty JSON object with a 200 response

Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
Oliver Davies 2025-09-20 23:01:29 +01:00
parent 055be3636b
commit fd6bac6da7
2 changed files with 23 additions and 0 deletions

1
go-api/.envrc Normal file
View file

@ -0,0 +1 @@
use flake "git+https://code.oliverdavies.uk/opdavies/dev-shells#go"

22
go-api/main.go Normal file
View file

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