mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-15 10:03:09 -06:00
Add commit hash to version API
Signed-off-by: Brian Meek <brian@hntlabs.com>
This commit is contained in:
parent
46f0ed379a
commit
6ffe8147f5
|
|
@ -19,6 +19,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||||
"github.com/matrix-org/dendrite/clientapi/api"
|
"github.com/matrix-org/dendrite/clientapi/api"
|
||||||
|
|
@ -41,6 +43,17 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var commitHash = func() string {
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, setting := range info.Settings {
|
||||||
|
if setting.Key == "vcs.revision" {
|
||||||
|
return setting.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}()
|
||||||
|
|
||||||
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
||||||
// to clients which need to make outbound HTTP requests.
|
// to clients which need to make outbound HTTP requests.
|
||||||
//
|
//
|
||||||
|
|
@ -101,6 +114,7 @@ func Setup(
|
||||||
JSON: struct {
|
JSON: struct {
|
||||||
Versions []string `json:"versions"`
|
Versions []string `json:"versions"`
|
||||||
UnstableFeatures map[string]bool `json:"unstable_features"`
|
UnstableFeatures map[string]bool `json:"unstable_features"`
|
||||||
|
CommitHash string `json:"commit_hash"`
|
||||||
}{Versions: []string{
|
}{Versions: []string{
|
||||||
"r0.0.1",
|
"r0.0.1",
|
||||||
"r0.1.0",
|
"r0.1.0",
|
||||||
|
|
@ -112,7 +126,7 @@ func Setup(
|
||||||
"v1.0",
|
"v1.0",
|
||||||
"v1.1",
|
"v1.1",
|
||||||
"v1.2",
|
"v1.2",
|
||||||
}, UnstableFeatures: unstableFeatures},
|
}, UnstableFeatures: unstableFeatures, CommitHash: commitHash},
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue