MCPcopy
hub / github.com/docker/compose / Ping

Method Ping

internal/desktop/client.go:112–135  ·  view source on GitHub ↗

Ping is a minimal API used to ensure that the server is available.

(ctx context.Context)

Source from the content-addressed store, hash-verified

110
111// Ping is a minimal API used to ensure that the server is available.
112func (c *Client) Ping(ctx context.Context) (*PingResponse, error) {
113 req, err := c.newRequest(ctx, http.MethodGet, "/ping", http.NoBody)
114 if err != nil {
115 return nil, err
116 }
117
118 resp, err := c.client.Do(req)
119 if err != nil {
120 return nil, err
121 }
122 defer func() {
123 _ = resp.Body.Close()
124 }()
125
126 if resp.StatusCode != http.StatusOK {
127 return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
128 }
129
130 var ret PingResponse
131 if err := json.NewDecoder(resp.Body).Decode(&ret); err != nil {
132 return nil, err
133 }
134 return &ret, nil
135}
136
137type FeatureFlagResponse map[string]FeatureFlagValue
138

Callers 1

TestClientPingFunction · 0.95

Calls 2

newRequestMethod · 0.95
CloseMethod · 0.65

Tested by 1

TestClientPingFunction · 0.76