Skip to content

Commit

Permalink
bytes.Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Sep 17, 2024
1 parent 8136d07 commit 9495404
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ import (
// https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/
func (c *Client) ListMetrics(ctx context.Context, opts MetricsOptions) (*MetricsResponse, error) {

Check failure on line 17 in analytics.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: Client

Check failure on line 17 in analytics.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: Client
url := fmt.Sprintf("%s", metricsEndpoint)
mRequest, err := json.Marshal(opts)

var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(opts)
if err != nil {
return nil, errors.Wrap(err, "while marshalling analytics metrics request")
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(mRequest))

req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, &buf)
if err != nil {
return nil, errors.Wrap(err, "while creating analytics metrics request")
}
Expand Down

0 comments on commit 9495404

Please sign in to comment.