aboutsummaryrefslogtreecommitdiff
path: root/server/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/web.go')
-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})