diff options
| author | Christine Dodrill <me@christine.website> | 2019-06-05 14:00:57 +0000 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2019-06-05 14:00:57 +0000 |
| commit | ce25d9fbfd79fba32977f2af9aa8169b6aed4d97 (patch) | |
| tree | c0b1acd2719992b79b006853edeb554d4a9976c0 /cmd | |
| parent | 5a5b7083b4dc010ce9825415697b26e7f2f0e980 (diff) | |
| download | xesite-ce25d9fbfd79fba32977f2af9aa8169b6aed4d97.tar.xz xesite-ce25d9fbfd79fba32977f2af9aa8169b6aed4d97.zip | |
cmd/site: add X-Git-Rev header to all outgoing requests
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/site/main.go | 5 |
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) } |
