MCPcopy Create free account
hub / github.com/cli/cli / ForwardPort

Method ForwardPort

internal/codespaces/connection/tunnels_api_server_mock.go:298–319  ·  view source on GitHub ↗
(ctx context.Context, port uint16)

Source from the content-addressed store, hash-verified

296}
297
298func (rs *relayServer) ForwardPort(ctx context.Context, port uint16) error {
299 pfr := messages.NewPortForwardRequest("127.0.0.1", uint32(port))
300 b, err := pfr.Marshal()
301 if err != nil {
302 return fmt.Errorf("error marshaling port forward request: %w", err)
303 }
304
305 replied, data, err := rs.serverConn.SendRequest(messages.PortForwardRequestType, true, b)
306 if err != nil {
307 return fmt.Errorf("error sending port forward request: %w", err)
308 }
309
310 if !replied {
311 return fmt.Errorf("port forward request not replied")
312 }
313
314 if data == nil {
315 return fmt.Errorf("no data returned")
316 }
317
318 return nil
319}
320
321func makeConnection(server *relayServer) http.HandlerFunc {
322 return func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected