add more stuff to api

This commit is contained in:
Jeffrey Paul 2019-11-05 17:21:30 -08:00
parent eaf0a60192
commit 5023155190
1 changed files with 11 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package feta
import "time"
import "net/http"
import "encoding/json"
import "runtime"
import "github.com/gin-gonic/gin"
@ -38,11 +39,17 @@ func (a *FetaAPIServer) getIndexHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
index := &gin.H{
"page": "index",
"instances": a.instances(),
"status": "ok",
"now": time.Now().UTC().Format(time.RFC3339),
"uptime": a.feta.Uptime().String(),
"server": &gin.H{
"now": time.Now().UTC().Format(time.RFC3339),
"uptime": a.feta.Uptime().String(),
"goroutines": runtime.NumGoroutine(),
"goversion": runtime.Version(),
"version": a.feta.version,
"buildtime": a.feta.buildtime,
"buildarch": a.feta.buildarch,
"builduser": a.feta.builduser,
},
}
json, err := json.Marshal(index)