Merge pull request #772 from influxdata/ga-version-header

Add X-Chronograf-Version header
pull/796/head
Nathan Haugo 2017-01-24 11:12:35 -08:00 committed by GitHub
commit 447cc299e3
4 changed files with 17 additions and 1 deletions

View File

@ -18,6 +18,7 @@
3. [#564](https://github.com/influxdata/chronograf/issues/564): Add RabbitMQ pre-canned layout
4. [#706](https://github.com/influxdata/chronograf/issues/706): Alerts on threshold where value is inside of range
5. [#707](https://github.com/influxdata/chronograf/issues/707): Alerts on threshold where value is outside of range
6. [#772](https://github.com/influxdata/chronograf/pull/772): Add X-Chronograf-Version header to all requests
### UI Improvements
1. [#766](https://github.com/influxdata/chronograf/pull/766): Add click-to-insert functionality to rule message templates

View File

@ -3,7 +3,7 @@ COMMIT ?= $(shell git rev-parse --short=8 HEAD)
SOURCES := $(shell find . -name '*.go')
LDFLAGS=-ldflags "-s -X main.Version=${VERSION} -X main.Commit=${COMMIT}"
LDFLAGS=-ldflags "-s -X main.version=${VERSION} -X main.commit=${COMMIT}"
BINARY=chronograf
default: dep build

View File

@ -76,6 +76,8 @@ func (s *Server) Serve() error {
UseAuth: s.useAuth(),
}, service)
s.handler = Version(s.BuildInfo.Version, s.handler)
var err error
s.Listener, err = net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)))
if err != nil {

13
server/version.go Normal file
View File

@ -0,0 +1,13 @@
package server
import (
"net/http"
)
func Version(version string, h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("X-Chronograf-Version", version)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}