MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / makePingPostReq

Function makePingPostReq

pkg/wcloud/wcloud.go:269–291  ·  view source on GitHub ↗
(ctx context.Context, apiUrl string, data interface{})

Source from the content-addressed store, hash-verified

267}
268
269func makePingPostReq(ctx context.Context, apiUrl string, data interface{}) (*http.Request, error) {
270 endpoint := GetPingEndpoint()
271 if endpoint == "" {
272 return nil, errors.New("wcloud ping endpoint not set")
273 }
274 var dataReader io.Reader
275 if data != nil {
276 byteArr, err := json.Marshal(data)
277 if err != nil {
278 return nil, fmt.Errorf("error marshaling json for %s request: %v", apiUrl, err)
279 }
280 dataReader = bytes.NewReader(byteArr)
281 }
282 fullUrl := endpoint + apiUrl
283 req, err := http.NewRequestWithContext(ctx, "POST", fullUrl, dataReader)
284 if err != nil {
285 return nil, fmt.Errorf("error creating %s request: %v", apiUrl, err)
286 }
287 req.Header.Set("Content-Type", "application/json")
288 req.Header.Set("X-PromptAPIVersion", strconv.Itoa(APIVersion))
289 req.Close = true
290 return req, nil
291}
292
293type PingInputType struct {
294 ClientId string `json:"clientid"`

Callers 1

SendDiagnosticPingFunction · 0.85

Calls 2

GetPingEndpointFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected