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

Method UpdateDirective

agent/utils/nginx/components/http.go:74–102  ·  view source on GitHub ↗
(key string, params []string)

Source from the content-addressed store, hash-verified

72}
73
74func (h *Http) UpdateDirective(key string, params []string) {
75 if key == "" || len(params) == 0 {
76 return
77 }
78 directives := h.GetDirectives()
79 index := -1
80 for i, dir := range directives {
81 if dir.GetName() == key {
82 if IsRepeatKey(key) {
83 oldParams := dir.GetParameters()
84 if !(len(oldParams) > 0 && oldParams[0] == params[0]) {
85 continue
86 }
87 }
88 index = i
89 break
90 }
91 }
92 newDirective := &Directive{
93 Name: key,
94 Parameters: params,
95 }
96 if index > -1 {
97 directives[index] = newDirective
98 } else {
99 directives = append(directives, newDirective)
100 }
101 h.Directives = directives
102}
103
104func (h *Http) RemoveDirective(key string, params []string) {
105 directives := h.GetDirectives()

Callers

nothing calls this directly

Calls 4

GetDirectivesMethod · 0.95
IsRepeatKeyFunction · 0.85
GetNameMethod · 0.65
GetParametersMethod · 0.65

Tested by

no test coverage detected