1
This commit is contained in:
27
internal/http/build_info.go
Normal file
27
internal/http/build_info.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user