MCPcopy
hub / github.com/basecamp/once / verifyHTTP

Method verifyHTTP

internal/docker/application.go:374–397  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

372}
373
374func (a *Application) verifyHTTP(ctx context.Context) error {
375 url := a.URL()
376 if url == "" {
377 return nil
378 }
379
380 client := &http.Client{Timeout: httpVerifyTimeout}
381 req, err := http.NewRequestWithContext(ctx, http.MethodGet, url+HealthCheckPath, nil)
382 if err != nil {
383 return fmt.Errorf("%w: %w", ErrVerificationFailed, err)
384 }
385
386 resp, err := client.Do(req)
387 if err != nil {
388 return fmt.Errorf("%w: %w", ErrVerificationFailed, err)
389 }
390 defer resp.Body.Close()
391
392 if resp.StatusCode < 200 || resp.StatusCode > 299 {
393 return fmt.Errorf("%w: unexpected status %d from %s", ErrVerificationFailed, resp.StatusCode, url)
394 }
395
396 return nil
397}
398
399func (a *Application) removeContainersExcept(ctx context.Context, keep string) error {
400 containers, err := a.namespace.client.ContainerList(ctx, container.ListOptions{All: true})

Callers 6

VerifyHTTPOrRemoveMethod · 0.95
TestVerifyHTTP_SuccessFunction · 0.95
TestVerifyHTTP_NoHostFunction · 0.95

Calls 2

URLMethod · 0.95
CloseMethod · 0.45

Tested by 5

TestVerifyHTTP_SuccessFunction · 0.76
TestVerifyHTTP_NoHostFunction · 0.76