2023-04-12 21:23:49 +00:00
|
|
|
package diagnostics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"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) {
|
|
|
|
metricsMux.HandleFunc("/debug/metrics/version", func(w http.ResponseWriter, r *http.Request) {
|
2023-04-12 21:23:49 +00:00
|
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
|
|
writeVersion(w)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func writeVersion(w io.Writer) {
|
|
|
|
fmt.Fprintf(w, "SUCCESS\n")
|
|
|
|
fmt.Fprintf(w, "%d\n", Version)
|
|
|
|
fmt.Fprintf(w, "%s\n", params.VersionWithMeta)
|
|
|
|
fmt.Fprintf(w, "%s\n", params.GitCommit)
|
|
|
|
}
|