MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / UpdateDirective

Method UpdateDirective

agent/utils/nginx/components/location.go:175–203  ·  view source on GitHub ↗
(key string, params []string)

Source from the content-addressed store, hash-verified

173}
174
175func (l *Location) UpdateDirective(key string, params []string) {
176 if key == "" || len(params) == 0 {
177 return
178 }
179 directives := l.Directives
180 index := -1
181 for i, dir := range directives {
182 if dir.GetName() == key {
183 if IsRepeatKey(key) {
184 oldParams := dir.GetParameters()
185 if !(len(oldParams) > 0 && oldParams[0] == params[0]) {
186 continue
187 }
188 }
189 index = i
190 break
191 }
192 }
193 newDirective := &Directive{
194 Name: key,
195 Parameters: params,
196 }
197 if index > -1 {
198 directives[index] = newDirective
199 } else {
200 directives = append(directives, newDirective)
201 }
202 l.Directives = directives
203}
204
205// RemoveDirective removes a directive by its name and optional FIRST parameter match
206func (l *Location) RemoveDirective(key string, params []string) {

Callers 3

AddServerCacheMethod · 0.95
AddSubFilterMethod · 0.95
OperateProxyMethod · 0.95

Calls 3

IsRepeatKeyFunction · 0.85
GetNameMethod · 0.65
GetParametersMethod · 0.65

Tested by

no test coverage detected