feat: computer data uptime

also fix last commit
This commit is contained in:
trafficlunar 2025-07-20 21:38:37 +01:00
parent 02740548de
commit 84dfe05de8
3 changed files with 13 additions and 4 deletions

View file

@ -52,12 +52,17 @@ func NewRouter() {
// Prometheus
r.Handle("/metrics", promhttp.Handler())
var commit = "unknown"
if os.Getenv("SOURCE_COMMIT") != "" {
commit = os.Getenv("SOURCE_COMMIT")[:7] // shorten to 7 characters
}
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{
"name": "trafficlunar's api",
"url": "https://github.com/trafficlunar/api",
"commit": os.Getenv("SOURCE_COMMIT")[:7], // shorten to 7 characters
"commit": commit,
})
})
r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {