create map on demand

This commit is contained in:
Gerhard Tan 2024-02-19 12:31:58 +08:00 committed by GitHub
parent e00916cb39
commit 4811166782
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -170,18 +170,18 @@ func Convert_ServerCommonConf_To_v1(conf *ServerCommonConf) *v1.ServerConfig {
func transformHeadersFromPluginParams(params map[string]string) v1.HeaderOperations {
out := v1.HeaderOperations{}
set := make(map[string]string)
for k, v := range params {
if !strings.HasPrefix(k, "plugin_header_") {
continue
}
if k = strings.TrimPrefix(k, "plugin_header_"); k != "" {
set[k] = v
if out.Set == nil {
out.Set = map[string]string{k: v}
} else {
out.Set[k] = v
}
}
}
if len(set) > 0 {
out.Set = set
}
return out
}