diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-09-22 09:32:59 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-09-22 09:34:48 -0700 |
commit | 23bd99623e5ec85642b331ec5f76698bbf2ed588 (patch) | |
tree | f4d154b8e666a78f1a75b123ed7490a0da6e22cc | |
parent | 23cb2009196cdf604ad9f0a77ff7544d7a25b5e0 (diff) | |
download | podman-23bd99623e5ec85642b331ec5f76698bbf2ed588.tar.gz podman-23bd99623e5ec85642b331ec5f76698bbf2ed588.tar.bz2 podman-23bd99623e5ec85642b331ec5f76698bbf2ed588.zip |
Add Server header to API service responses
Aids in reading logs of different services
Signed-off-by: Jhon Honce <jhonce@redhat.com>
-rw-r--r-- | pkg/api/server/handler_api.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pkg/api/server/handler_api.go b/pkg/api/server/handler_api.go index f2ce0301b..920811c51 100644 --- a/pkg/api/server/handler_api.go +++ b/pkg/api/server/handler_api.go @@ -34,15 +34,18 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc { } // TODO: Use r.ConnContext when ported to go 1.13 - c := context.WithValue(r.Context(), "decoder", s.Decoder) //nolint - c = context.WithValue(c, "runtime", s.Runtime) //nolint - c = context.WithValue(c, "shutdownFunc", s.Shutdown) //nolint - c = context.WithValue(c, "idletracker", s.idleTracker) //nolint + c := context.WithValue(r.Context(), "decoder", s.Decoder) // nolint + c = context.WithValue(c, "runtime", s.Runtime) // nolint + c = context.WithValue(c, "shutdownFunc", s.Shutdown) // nolint + c = context.WithValue(c, "idletracker", s.idleTracker) // nolint r = r.WithContext(c) - v := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion] - w.Header().Set("API-Version", fmt.Sprintf("%d.%d", v.Major, v.Minor)) - w.Header().Set("Libpod-API-Version", utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String()) + cv := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion] + w.Header().Set("API-Version", fmt.Sprintf("%d.%d", cv.Major, cv.Minor)) + + lv := utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String() + w.Header().Set("Libpod-API-Version", lv) + w.Header().Set("Server", "Libpod/"+lv+" ("+runtime.GOOS+")") h(w, r) } |