MCPcopy
hub / github.com/docker/docker-agent / ContextWithSessionID

Function ContextWithSessionID

pkg/httpclient/session.go:12–14  ·  view source on GitHub ↗

ContextWithSessionID returns a new context carrying the given session ID. When set, [userAgentTransport.RoundTrip] forwards it as the `X-Cagent-Session-Id` header — but only on gateway-bound requests (those already carrying `X-Cagent-Forward`), to keep the identifier out of direct provider calls and

(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

10// (those already carrying `X-Cagent-Forward`), to keep the identifier
11// out of direct provider calls and unrelated outbound HTTP.
12func ContextWithSessionID(ctx context.Context, id string) context.Context {
13 return context.WithValue(ctx, sessionIDKey{}, id)
14}
15
16// SessionIDFromContext returns the session ID stored on ctx by
17// [ContextWithSessionID], or the empty string if none is set.

Callers 5

GenerateMethod · 0.92
runStreamLoopMethod · 0.92
compactWithReasonMethod · 0.92

Calls

no outgoing calls