MCPcopy Index your code
hub / github.com/github/copilot-sdk / CopilotWebSocketForwarder

Struct CopilotWebSocketForwarder

go/copilot_request_handler.go:374–393  ·  view source on GitHub ↗

CopilotWebSocketForwarder is the default [CopilotWebSocketHandler]: it dials the real upstream and runs a receive loop forwarding upstream→runtime messages. Set OnSendRequestMessage / OnSendResponseMessage to observe, transform, or drop messages in either direction.

Source from the content-addressed store, hash-verified

372// messages. Set OnSendRequestMessage / OnSendResponseMessage to observe,
373// transform, or drop messages in either direction.
374type CopilotWebSocketForwarder struct {
375 URL string
376 Headers http.Header
377 // OnSendRequestMessage observes or transforms each runtime→upstream frame.
378 // The frame type (text vs binary) is available via the message's Binary
379 // field and may be changed in the returned message. Return nil to drop the
380 // frame.
381 OnSendRequestMessage func(msg CopilotWebSocketMessage) *CopilotWebSocketMessage
382 // OnSendResponseMessage observes or transforms each upstream→runtime frame.
383 // The frame type (text vs binary) is available via the message's Binary
384 // field and may be changed in the returned message. Return nil to drop the
385 // frame.
386 OnSendResponseMessage func(msg CopilotWebSocketMessage) *CopilotWebSocketMessage
387
388 conn *websocket.Conn
389 resp WebSocketResponseWriter
390 done chan struct{}
391 err error
392 closeOnce sync.Once
393}
394
395// NewCopilotWebSocketForwarder creates a forwarding handler targeting
396// url with the given handshake headers.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected