aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-06-05 14:00:57 +0000
committerChristine Dodrill <me@christine.website>2019-06-05 14:00:57 +0000
commitce25d9fbfd79fba32977f2af9aa8169b6aed4d97 (patch)
treec0b1acd2719992b79b006853edeb554d4a9976c0
parent5a5b7083b4dc010ce9825415697b26e7f2f0e980 (diff)
downloadxesite-ce25d9fbfd79fba32977f2af9aa8169b6aed4d97.tar.xz
xesite-ce25d9fbfd79fba32977f2af9aa8169b6aed4d97.zip
cmd/site: add X-Git-Rev header to all outgoing requests
-rw-r--r--cmd/site/main.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd/site/main.go b/cmd/site/main.go
index 92f636d..00a0292 100644
--- a/cmd/site/main.go
+++ b/cmd/site/main.go
@@ -65,12 +65,17 @@ type Site struct {
xffmw *xff.XFF
}
+var gitRev = os.Getenv("GIT_REV")
+
func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx := opname.With(r.Context(), "site.ServeHTTP")
ctx = ln.WithF(ctx, ln.F{
"user_agent": r.Header.Get("User-Agent"),
})
r = r.WithContext(ctx)
+ if gitRev != "" {
+ w.Header().Add("X-Git-Rev", gitRev)
+ }
middleware.RequestID(s.xffmw.Handler(ex.HTTPLog(s.mux))).ServeHTTP(w, r)
}