Return an empty JSON object with a 200 response
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
055be3636b
commit
fd6bac6da7
2 changed files with 23 additions and 0 deletions
1
go-api/.envrc
Normal file
1
go-api/.envrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use flake "git+https://code.oliverdavies.uk/opdavies/dev-shells#go"
|
22
go-api/main.go
Normal file
22
go-api/main.go
Normal 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)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue