Add custom header support for HTTP proxy

This commit is contained in:
PMExtra 2022-12-15 19:15:43 +08:00 committed by yuhan6665
parent d7ac6946d2
commit c9b6fc0104
4 changed files with 172 additions and 28 deletions

View file

@ -53,6 +53,7 @@ type HTTPRemoteConfig struct {
type HTTPClientConfig struct {
Servers []*HTTPRemoteConfig `json:"servers"`
Headers map[string]string `json:"headers"`
}
func (v *HTTPClientConfig) Build() (proto.Message, error) {
@ -77,5 +78,12 @@ func (v *HTTPClientConfig) Build() (proto.Message, error) {
}
config.Server[idx] = server
}
config.Header = make([]*http.Header, 0, 32)
for key, value := range v.Headers {
config.Header = append(config.Header, &http.Header{
Key: key,
Value: value,
})
}
return config, nil
}