From 7317a215f9044b73ea9d2da2ec214d857e0ea3aa Mon Sep 17 00:00:00 2001 From: Fabian Vowie Date: Mon, 27 Dec 2021 00:01:40 +0100 Subject: [PATCH] Add metadata response to index route --- main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a12eff1..5057f09 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,23 @@ package main import ( + "encoding/json" "net/http" "github.com/gorilla/mux" ) +const Name string = "Lithium" +const Version string = "0.1.0" + +type Metadata struct { + Name string + Version string +} + func IndexHandler(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("hello world!")) + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(Metadata{Name, Version}) } func main() {