MCPcopy Index your code
hub / github.com/coder/coder / extractContext

Function extractContext

agent/agentchat/headers.go:14–35  ·  view source on GitHub ↗

extractContext reads chat identity headers from the request. Returns zero values if headers are absent (non-chat request).

(r *http.Request)

Source from the content-addressed store, hash-verified

12// extractContext reads chat identity headers from the request.
13// Returns zero values if headers are absent (non-chat request).
14func extractContext(r *http.Request) (chatID uuid.UUID, ancestorIDs []uuid.UUID, ok bool) {
15 raw := r.Header.Get(workspacesdk.CoderChatIDHeader)
16 if raw == "" {
17 return uuid.Nil, nil, false
18 }
19 chatID, err := uuid.Parse(raw)
20 if err != nil {
21 return uuid.Nil, nil, false
22 }
23 rawAncestors := r.Header.Get(workspacesdk.CoderAncestorChatIDsHeader)
24 if rawAncestors != "" {
25 var ids []string
26 if err := json.Unmarshal([]byte(rawAncestors), &ids); err == nil {
27 for _, s := range ids {
28 if id, err := uuid.Parse(s); err == nil {
29 ancestorIDs = append(ancestorIDs, id)
30 }
31 }
32 }
33 }
34 return chatID, ancestorIDs, true
35}

Callers 1

MiddlewareFunction · 0.85

Calls 3

GetMethod · 0.65
ParseMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected