remove old auth header on Auth() call

This commit is contained in:
Tordarus 2025-02-11 12:45:20 +01:00
parent 9babe85048
commit 6142a1100c
2 changed files with 14 additions and 1 deletions

View File

@ -153,7 +153,10 @@ func HeadersMap(headers map[string]string) RequestModifier {
}
func Auth(auth AuthProvider) RequestModifier {
return Headers("Authentication", auth())
return chainMods(
RemoveHeaders("Authentication"),
Headers("Authentication", auth()),
)
}
func Basic(username, password string) AuthProvider {

10
utils.go Normal file
View File

@ -0,0 +1,10 @@
package ezhttp
func chainMods(mods ...RequestModifier) RequestModifier {
return func(r *RequestBuilder) *RequestBuilder {
for _, mod := range mods {
r = mod(r)
}
return r
}
}