mirror-nourybot/cmd/nourybot/status_page.go

23 lines
631 B
Go
Raw Normal View History

2023-12-10 20:13:06 +01:00
package main
import (
"fmt"
"io"
"net/http"
"github.com/lyx0/nourybot/internal/common"
)
func (app *application) statusPage() {
commit := common.GetVersion()
started := common.GetUptime().Format("2006-1-2 15:4:5")
commitLink := fmt.Sprintf("https://github.com/lyx0/nourybot/commit/%v", common.GetVersionPure())
2023-12-10 20:13:06 +01:00
statusHandler := func(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, fmt.Sprintf("started: \t%v\nenvironment: \t%v\ncommit: \t%v\ngithub: \t%v", started, app.Environment, commit, commitLink))
2023-12-10 20:13:06 +01:00
}
http.HandleFunc("/status", statusHandler)
app.Log.Fatal(http.ListenAndServe(":8080", nil))
}