mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
app: show unique ID in /api
This commit is contained in:
13
app/main.go
13
app/main.go
@@ -16,8 +16,13 @@ import (
|
||||
"github.com/weaveworks/scope/xfer"
|
||||
)
|
||||
|
||||
// Set during buildtime.
|
||||
var version = "dev"
|
||||
var (
|
||||
// Set at buildtime.
|
||||
version = "dev"
|
||||
|
||||
// Set at runtime.
|
||||
uniqueID = "0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
@@ -33,8 +38,8 @@ func main() {
|
||||
}
|
||||
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
id := strconv.FormatInt(rand.Int63(), 16)
|
||||
log.Printf("app starting, version %s, ID %s", version, id)
|
||||
uniqueID = strconv.FormatInt(rand.Int63(), 16)
|
||||
log.Printf("app starting, version %s, ID %s", version, uniqueID)
|
||||
|
||||
c := xfer.NewCollector(*window)
|
||||
http.Handle("/", Router(c))
|
||||
|
||||
@@ -121,11 +121,12 @@ func captureTopology(rep xfer.Reporter, f func(xfer.Reporter, topologyView, http
|
||||
|
||||
// APIDetails are some generic details that can be fetched from /api
|
||||
type APIDetails struct {
|
||||
ID string `json:"id"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func apiHandler(w http.ResponseWriter, r *http.Request) {
|
||||
respondWith(w, http.StatusOK, APIDetails{Version: version})
|
||||
respondWith(w, http.StatusOK, APIDetails{ID: uniqueID, Version: version})
|
||||
}
|
||||
|
||||
// Topology option labels should tell the current state. The first item must
|
||||
|
||||
Reference in New Issue
Block a user