MCPcopy Create free account
hub / github.com/anchordotdev/cli / startProxy

Method startProxy

api/apitest/apitest.go:260–283  ·  view source on GitHub ↗
(ctx context.Context, upstreamAddr string)

Source from the content-addressed store, hash-verified

258}
259
260func (s *Server) startProxy(ctx context.Context, upstreamAddr string) (string, func() error, error) {
261 addr, err := UnusedPort()
262 if err != nil {
263 return "", nil, err
264 }
265
266 host, port, err := net.SplitHostPort(addr)
267 if err != nil {
268 return "", nil, err
269 }
270
271 upstreamURL := "http://" + upstreamAddr + "/"
272
273 args := []string{
274 "npx", "prism", "proxy", oapiConfig, upstreamURL,
275 "--port", port, "--host", host,
276 }
277
278 wait, err := s.startCmd(ctx, args)
279 if err != nil {
280 return "", nil, err
281 }
282 return addr, wait, nil
283}
284
285func (s *Server) waitTCP(addr string) error {
286 var dialer net.Dialer

Callers 1

StartProxyMethod · 0.95

Calls 2

startCmdMethod · 0.95
UnusedPortFunction · 0.85

Tested by

no test coverage detected