From 87ae7c73ebe05f777e23087b1550d2cab42746ff Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Wed, 8 Aug 2018 21:55:02 +0100 Subject: Add version string Add `lib.Version` to get updated at build time. Add --version flags to cashier and cashierd Send client version in the signing request Send server version in http response headers and in signing response Set version at build time --- server/web.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'server') diff --git a/server/web.go b/server/web.go index d55aa52..840ce1b 100644 --- a/server/web.go +++ b/server/web.go @@ -306,6 +306,14 @@ func newState() string { return hex.EncodeToString(k) } +// mwVersion is middleware to add a X-Cashier-Version header to the response. +func mwVersion(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("X-Cashier-Version", lib.Version) + next.ServeHTTP(w, r) + }) +} + func runHTTPServer(conf *config.Server, l net.Listener) { var err error ctx := &appContext{ @@ -330,6 +338,7 @@ func runHTTPServer(conf *config.Server, l net.Listener) { CSRF := csrf.Protect([]byte(conf.CSRFSecret), csrf.Secure(conf.UseTLS)) r := mux.NewRouter() + r.Use(mwVersion) r.Methods("GET").Path("/").Handler(appHandler{ctx, rootHandler}) r.Methods("GET").Path("/auth/login").Handler(appHandler{ctx, loginHandler}) r.Methods("GET").Path("/auth/callback").Handler(appHandler{ctx, callbackHandler}) -- cgit v1.2.3