package server import ( "encoding/json" "log" "net/http" "time" ) const Version = "0.0.0" var start time.Time func init() { start = time.Now() } // Info provides server version and uptime stats func (c *Controller) Info(w http.ResponseWriter, req *http.Request) { log.Println("version requested") output := struct { Version string `json:"version"` Start string `json:"start"` Uptime string `json:"uptime"` }{ Version: Version, Start: start.Format("2006-01-02 15:04:05"), Uptime: time.Since(start).String(), } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(output) }