Skip to content

Commit

Permalink
🚀 add body data (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultleouay authored Jul 25, 2024
1 parent bdcd519 commit e771b72
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/checker/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ func SinglePing(ctx context.Context, client *http.Client, inputData request.Ping
return Response{}, fmt.Errorf("error with monitorURL %s: %w", inputData.URL, err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)

if err != nil {
return Response{
Latency: latency,
Timing: timing,
Time: start.UTC().UnixMilli(),
Error: fmt.Sprintf("Cannot read response body: %s", err.Error()),
}, fmt.Errorf("error with monitorURL %s: %w", inputData.URL, err)
}

headers := make(map[string]string)
for key := range res.Header {
Expand All @@ -243,5 +253,6 @@ func SinglePing(ctx context.Context, client *http.Client, inputData request.Ping
Headers: headers,
Timing: timing,
Latency: latency,
Body: string(body),
}, nil
}

0 comments on commit e771b72

Please sign in to comment.