MCPcopy
hub / github.com/caddyserver/caddy / SetVar

Function SetVar

modules/caddyhttp/vars.go:448–460  ·  view source on GitHub ↗

SetVar sets a value in the context's variable table with the given key. It overwrites any previous value with the same key. If the value is nil (note: non-nil interface with nil underlying value does not count) and the key exists in the table, the key+value will be deleted from the table.

(ctx context.Context, key string, value any)

Source from the content-addressed store, hash-verified

446// underlying value does not count) and the key exists in
447// the table, the key+value will be deleted from the table.
448func SetVar(ctx context.Context, key string, value any) {
449 varMap, ok := ctx.Value(VarsCtxKey).(map[string]any)
450 if !ok {
451 return
452 }
453 if value == nil {
454 if _, ok := varMap[key]; ok {
455 delete(varMap, key)
456 return
457 }
458 }
459 varMap[key] = value
460}
461
462// Interface guards
463var (

Callers 15

WriteHeaderMethod · 0.92
TestClientIPHashPolicyFunction · 0.92
NewTransportMethod · 0.92
ServeHTTPMethod · 0.92
proxyLoopIterationMethod · 0.92
prepareRequestMethod · 0.92
MatchMethod · 0.92
serveHTTPMethod · 0.92
MatchMethod · 0.85
MatchMethod · 0.85
MatchWithErrorMethod · 0.85

Calls 1

ValueMethod · 0.45