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

Method checkHTTP

lcl/bootstrap.go:263–312  ·  view source on GitHub ↗
(ctx context.Context, cfg *cli.Config, drv *ui.Driver, srv *api.Service, diagPort string, requestc <-chan string)

Source from the content-addressed store, hash-verified

261}
262
263func (c Bootstrap) checkHTTP(ctx context.Context, cfg *cli.Config, drv *ui.Driver, srv *api.Service, diagPort string, requestc <-chan string) (bool, error) {
264 domain := srv.Slug + ".lcl.host" // TODO: look this up properly
265
266 httpURL, err := url.Parse("http://" + domain + ":" + diagPort)
267 if err != nil {
268 return false, err
269 }
270 httpConfirmCh := make(chan struct{})
271
272 drv.Activate(ctx, &models.Bootstrap{
273 ConfirmCh: httpConfirmCh,
274
275 Domain: domain,
276 Port: diagPort,
277 Scheme: "http",
278 ShowHeader: true,
279 })
280
281 drv.Send(models.OpenURLMsg(httpURL.String()))
282
283 select {
284 case <-httpConfirmCh:
285 case <-ctx.Done():
286 return false, ctx.Err()
287 }
288
289 var browserless bool
290 if !cfg.Trust.MockMode {
291 if err := browser.OpenURL(httpURL.String()); err != nil {
292 browserless = true
293 drv.Activate(ctx, models.Browserless)
294 }
295 }
296
297 var requestedScheme string
298 if !browserless {
299 select {
300 case requestedScheme = <-requestc:
301 case <-ctx.Done():
302 return false, ctx.Err()
303 }
304 }
305
306 if requestedScheme == "https" {
307 drv.Activate(ctx, new(models.BootstrapSuccess))
308 return true, nil
309 }
310
311 return false, nil
312}
313
314func (c Bootstrap) checkHTTPS(ctx context.Context, cfg *cli.Config, drv *ui.Driver, srv *api.Service, diagPort string, requestc <-chan string) error {
315 domain := srv.Slug + ".lcl.host" // TODO: look this up properly

Callers 1

performMethod · 0.95

Calls 3

ActivateMethod · 0.80
SendMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected