You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
630 B
32 lines
630 B
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) |
|
}
|
|
|