aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2018-08-08 21:55:02 +0100
committerNiall Sheridan <nsheridan@gmail.com>2018-08-10 18:35:13 +0100
commit87ae7c73ebe05f777e23087b1550d2cab42746ff (patch)
tree45e4ea4ce48385ebbb9ba83447bfb5d66d97dea7 /server
parent3e006c39b0a4411e91e80de261d0e7b5353d44c0 (diff)
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
Diffstat (limited to 'server')
-rw-r--r--server/web.go9
1 files changed, 9 insertions, 0 deletions
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})