29 lines
567 B
Go
29 lines
567 B
Go
package internal
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var Debug = os.Getenv("PEGASUS_DEBUG") == "1"
|
|
var DryRun = os.Getenv("PEGASUS_DRY_RUN") == "1"
|
|
|
|
func Logf(format string, args ...any) {
|
|
if Debug { log.Printf(format, args...) }
|
|
}
|
|
|
|
func RedactHeaders(h http.Header) http.Header {
|
|
cp := http.Header{}
|
|
for k, v := range h {
|
|
kk := strings.ToLower(k)
|
|
if kk == "cookie" || strings.HasPrefix(kk, "authorization") || strings.Contains(kk, "token") {
|
|
cp[k] = []string{"<redacted>"}
|
|
} else {
|
|
cp[k] = append([]string(nil), v...)
|
|
}
|
|
}
|
|
return cp
|
|
}
|