Browse Source

Add metadata response to index route

feature/add-metadata-endpoint
Fabian Vowie 3 years ago
parent
commit
7317a215f9
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 12
      main.go

12
main.go

@ -1,13 +1,23 @@
package main package main
import ( import (
"encoding/json"
"net/http" "net/http"
"github.com/gorilla/mux" "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) { 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() { func main() {

Loading…
Cancel
Save