mirror of
https://github.com/sajari/docconv.git
synced 2026-10-18 06:31:24 +08:00
23 lines
398 B
Go
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))
|
|
}
|