@@ -108,7 +108,7 @@ type CopilotRequestHandler struct {
108108 // used. RoundTrip is called directly, so redirects are not followed.
109109 Transport http.RoundTripper
110110 // OpenWebSocket returns a per-connection WebSocket handler. When nil a
111- // transparent [ForwardingCopilotWebSocketHandler ] to the request URL is opened.
111+ // transparent [CopilotWebSocketForwarder ] to the request URL is opened.
112112 OpenWebSocket func (ctx * CopilotRequestContext ) (CopilotWebSocketHandler , error )
113113}
114114
@@ -124,7 +124,7 @@ type WebSocketResponseWriter interface {
124124
125125// CopilotWebSocketHandler is a per-connection WebSocket handler returned by
126126// [CopilotRequestHandler.OpenWebSocket]. The default implementation is
127- // [ForwardingCopilotWebSocketHandler ]; a full transport replacement implements
127+ // [CopilotWebSocketForwarder ]; a full transport replacement implements
128128// this interface directly.
129129type CopilotWebSocketHandler interface {
130130 // Open establishes the connection and starts forwarding upstream→runtime
@@ -255,7 +255,7 @@ func (h *CopilotRequestHandler) handleWebSocket(rctx *CopilotRequestContext, sin
255255 if h .OpenWebSocket != nil {
256256 handler , err = h .OpenWebSocket (rctx )
257257 } else {
258- handler = NewForwardingCopilotWebSocketHandler (rctx .URL , rctx .Headers )
258+ handler = NewCopilotWebSocketForwarder (rctx .URL , rctx .Headers )
259259 }
260260 if err != nil {
261261 return err
@@ -365,11 +365,11 @@ func (w *wsResponseWriter) fail(message string, code string) error {
365365 return w .sink .sinkError (message , code )
366366}
367367
368- // ForwardingCopilotWebSocketHandler is the default [CopilotWebSocketHandler]:
368+ // CopilotWebSocketForwarder is the default [CopilotWebSocketHandler]:
369369// it dials the real upstream and runs a receive loop forwarding upstream→runtime
370370// messages. Set OnSendRequestMessage / OnSendResponseMessage to observe,
371371// transform, or drop messages in either direction.
372- type ForwardingCopilotWebSocketHandler struct {
372+ type CopilotWebSocketForwarder struct {
373373 URL string
374374 Headers http.Header
375375 // OnSendRequestMessage observes or transforms each runtime→upstream frame.
@@ -390,13 +390,13 @@ type ForwardingCopilotWebSocketHandler struct {
390390 closeOnce sync.Once
391391}
392392
393- // NewForwardingCopilotWebSocketHandler creates a forwarding handler targeting
393+ // NewCopilotWebSocketForwarder creates a forwarding handler targeting
394394// url with the given handshake headers.
395- func NewForwardingCopilotWebSocketHandler (url string , headers http.Header ) * ForwardingCopilotWebSocketHandler {
396- return & ForwardingCopilotWebSocketHandler {URL : url , Headers : headers , done : make (chan struct {})}
395+ func NewCopilotWebSocketForwarder (url string , headers http.Header ) * CopilotWebSocketForwarder {
396+ return & CopilotWebSocketForwarder {URL : url , Headers : headers , done : make (chan struct {})}
397397}
398398
399- func (f * ForwardingCopilotWebSocketHandler ) Open (ctx context.Context , resp WebSocketResponseWriter ) error {
399+ func (f * CopilotWebSocketForwarder ) Open (ctx context.Context , resp WebSocketResponseWriter ) error {
400400 f .resp = resp
401401 if f .done == nil {
402402 f .done = make (chan struct {})
@@ -412,7 +412,7 @@ func (f *ForwardingCopilotWebSocketHandler) Open(ctx context.Context, resp WebSo
412412 return nil
413413}
414414
415- func (f * ForwardingCopilotWebSocketHandler ) dialHeaders () http.Header {
415+ func (f * CopilotWebSocketForwarder ) dialHeaders () http.Header {
416416 out := http.Header {}
417417 for name , values := range f .Headers {
418418 if isForbiddenRequestHeader (name ) {
@@ -425,7 +425,7 @@ func (f *ForwardingCopilotWebSocketHandler) dialHeaders() http.Header {
425425 return out
426426}
427427
428- func (f * ForwardingCopilotWebSocketHandler ) receiveLoop (ctx context.Context ) {
428+ func (f * CopilotWebSocketForwarder ) receiveLoop (ctx context.Context ) {
429429 defer close (f .done )
430430 for {
431431 typ , data , err := f .conn .Read (ctx )
@@ -455,7 +455,7 @@ func (f *ForwardingCopilotWebSocketHandler) receiveLoop(ctx context.Context) {
455455 }
456456}
457457
458- func (f * ForwardingCopilotWebSocketHandler ) SendRequestMessage (ctx context.Context , msg CopilotWebSocketMessage ) error {
458+ func (f * CopilotWebSocketForwarder ) SendRequestMessage (ctx context.Context , msg CopilotWebSocketMessage ) error {
459459 out := msg
460460 if f .OnSendRequestMessage != nil {
461461 transformed := f .OnSendRequestMessage (msg )
@@ -474,10 +474,10 @@ func (f *ForwardingCopilotWebSocketHandler) SendRequestMessage(ctx context.Conte
474474 return f .conn .Write (ctx , msgType , out .Data )
475475}
476476
477- func (f * ForwardingCopilotWebSocketHandler ) Done () <- chan struct {} { return f .done }
478- func (f * ForwardingCopilotWebSocketHandler ) Err () error { return f .err }
477+ func (f * CopilotWebSocketForwarder ) Done () <- chan struct {} { return f .done }
478+ func (f * CopilotWebSocketForwarder ) Err () error { return f .err }
479479
480- func (f * ForwardingCopilotWebSocketHandler ) Close () error {
480+ func (f * CopilotWebSocketForwarder ) Close () error {
481481 f .closeOnce .Do (func () {
482482 if f .conn != nil {
483483 _ = f .conn .Close (websocket .StatusNormalClosure , "" )
0 commit comments