Add custom header support for HTTP proxy

This commit is contained in:
PMExtra authored and yuhan6665 committed 2022-12-18 21:48:23 -05:00
1 parent d7ac6946d2
commit c9b6fc0104
4 files changed
+172 -28

No files matched your search

+8
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
}