28 lines
588 B
Go
28 lines
588 B
Go
package http_router
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func (h *handler) getBuildInfoHandler(w http.ResponseWriter, _ *http.Request) {
|
|
response := struct {
|
|
Version string `json:"version"`
|
|
Commit string `json:"commit"`
|
|
Date string `json:"date"`
|
|
}{
|
|
Version: h.buildConfig.Version,
|
|
Commit: h.buildConfig.Commit,
|
|
Date: h.buildConfig.Date,
|
|
}
|
|
|
|
responseJSON, err := json.Marshal(response)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write(responseJSON)
|
|
}
|