2023-04-12 21:23:49 +00:00
|
|
|
package diagnostics
|
|
|
|
|
|
|
|
import (
|
2023-09-25 15:24:17 +00:00
|
|
|
"encoding/json"
|
2023-04-12 21:23:49 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon/params"
|
|
|
|
)
|
|
|
|
|
2023-06-02 11:08:53 +00:00
|
|
|
const Version = 3
|
2023-04-12 21:23:49 +00:00
|
|
|
|
2023-08-31 08:04:27 +00:00
|
|
|
func SetupVersionAccess(metricsMux *http.ServeMux) {
|
2023-09-25 15:24:17 +00:00
|
|
|
metricsMux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
|
2023-04-12 21:23:49 +00:00
|
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
2023-09-25 15:24:17 +00:00
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
json.NewEncoder(w).Encode(struct {
|
|
|
|
Node int `json:"nodeVersion"`
|
|
|
|
Code string `json:"codeVersion"`
|
|
|
|
Git string `json:"gitCommit"`
|
|
|
|
}{
|
|
|
|
Node: Version,
|
|
|
|
Code: params.VersionWithMeta,
|
|
|
|
Git: params.GitCommit,
|
|
|
|
})
|
2023-04-12 21:23:49 +00:00
|
|
|
})
|
|
|
|
}
|