fix nil map error when using plugin headers in legacy format

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

View File

@ -170,14 +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 != "" {
out.Set[k] = v
set[k] = v
}
}
if len(set) > 0 {
out.Set = set
}
return out
}