Files
2023-10-30 16:53:28 +11:00

23 lines
398 B
Go

package debug
import (
"context"
"net/http"
"strconv"
)
type HTTPHandler struct {
// Handler to wrap.
Handler http.Handler
}
func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if ok, _ := strconv.ParseBool(r.Header.Get(DebugHeader)); ok {
ctx = context.WithValue(ctx, debugEnabledKey{}, true)
}
h.Handler.ServeHTTP(w, r.WithContext(ctx))
}