parent
b5cac7c02a
commit
5cac75b638
@ -0,0 +1,32 @@ |
||||
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) |
||||
} |
Loading…
Reference in new issue