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

Method Dial

codersdk/client.go:366–393  ·  view source on GitHub ↗
(ctx context.Context, path string, opts *websocket.DialOptions)

Source from the content-addressed store, hash-verified

364}
365
366func (c *Client) Dial(ctx context.Context, path string, opts *websocket.DialOptions) (*websocket.Conn, error) {
367 u, err := c.URL.Parse(path)
368 if err != nil {
369 return nil, err
370 }
371
372 if opts == nil {
373 opts = &websocket.DialOptions{}
374 }
375 // Propagate the client's HTTP client to the websocket dialer
376 // so that custom TLS configurations (e.g. mesh TLS between
377 // replicas) are used for the handshake request. Without this,
378 // the websocket library falls back to http.DefaultClient.
379 if opts.HTTPClient == nil {
380 opts.HTTPClient = c.HTTPClient
381 }
382 c.SessionTokenProvider.SetDialOption(opts)
383
384 conn, resp, err := websocket.Dial(ctx, u.String(), opts)
385 if resp != nil && resp.Body != nil {
386 resp.Body.Close()
387 }
388 if err != nil {
389 return nil, err
390 }
391
392 return conn, nil
393}
394
395// ExpectJSONMime is a helper function that will assert the content type
396// of the response is application/json.

Callers 1

Calls 5

ParseMethod · 0.65
SetDialOptionMethod · 0.65
DialMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected