Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Use constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Sep 9, 2020
1 parent 1459c28 commit 035b543
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/controller/middleware/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ import (
"github.com/gorilla/mux"
)

const HeaderDebug = "x-debug"
const (
HeaderDebug = "x-debug"
HeaderDebugBuildID = "x-build-id"
HeaderDebugBuildTag = "x-build-tag"
)

// ProcessDebug adds additional debugging information to the response if the
// request included the "X-Debug" header with any value.
func ProcessDebug(ctx context.Context) mux.MiddlewareFunc {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get(HeaderDebug) != "" {
w.Header().Set("x-build-id", buildinfo.BuildID)
w.Header().Set("x-build-tag", buildinfo.BuildTag)
w.Header().Set(HeaderDebugBuildID, buildinfo.BuildID)
w.Header().Set(HeaderDebugBuildTag, buildinfo.BuildTag)
}

next.ServeHTTP(w, r)
Expand Down

0 comments on commit 035b543

Please sign in to comment.