30 lines
650 B
Go
30 lines
650 B
Go
![]() |
package routes
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
|
||
|
"git.1e99.eu/1e99/status/services"
|
||
|
)
|
||
|
|
||
|
func Index(serviceList []*services.Service) http.HandlerFunc {
|
||
|
return func(res http.ResponseWriter, req *http.Request) {
|
||
|
fmt.Fprintf(res, "Services:\n")
|
||
|
|
||
|
for _, service := range serviceList {
|
||
|
status, lastCheck := service.Status()
|
||
|
statusName := ""
|
||
|
switch status {
|
||
|
case services.StatusDown:
|
||
|
statusName = "Down"
|
||
|
case services.StatusUp:
|
||
|
statusName = "Up"
|
||
|
case services.StatusUnknown:
|
||
|
statusName = "Unknwon"
|
||
|
}
|
||
|
|
||
|
fmt.Fprintf(res, " %s: %s (Last checked: %s)\n", service.Name, statusName, lastCheck.Format("15:04:05 MST"))
|
||
|
}
|
||
|
}
|
||
|
}
|