mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
* Allow custom headers in validator client HTTP requests * changelog <3 * improve flag description * Bastin's review * James' review * add godoc for NodeConnectionOption
26 lines
613 B
Go
26 lines
613 B
Go
package client
|
|
|
|
import "net/http"
|
|
|
|
// CustomHeadersTransport adds custom headers to each request
|
|
type CustomHeadersTransport struct {
|
|
base http.RoundTripper
|
|
headers map[string][]string
|
|
}
|
|
|
|
func NewCustomHeadersTransport(base http.RoundTripper, headers map[string][]string) *CustomHeadersTransport {
|
|
return &CustomHeadersTransport{
|
|
base: base,
|
|
headers: headers,
|
|
}
|
|
}
|
|
|
|
func (t *CustomHeadersTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
for header, values := range t.headers {
|
|
for _, value := range values {
|
|
req.Header.Add(header, value)
|
|
}
|
|
}
|
|
return t.base.RoundTrip(req)
|
|
}
|