feat: show commit hash in index route

only works on coolify or if you specify the SOURCE_COMMIT environment
variable manually
This commit is contained in:
trafficlunar 2025-07-20 16:28:20 +01:00
parent af790e5765
commit 02740548de

View file

@ -55,8 +55,9 @@ func NewRouter() {
r.Get("/", func(w http.ResponseWriter, r *http.Request) { r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{ json.NewEncoder(w).Encode(map[string]string{
"name": "trafficlunar's api", "name": "trafficlunar's api",
"url": "https://github.com/trafficlunar/api", "url": "https://github.com/trafficlunar/api",
"commit": os.Getenv("SOURCE_COMMIT")[:7], // shorten to 7 characters
}) })
}) })
r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { r.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {