confirmSubscription GETs the (already host-allow-listed) SubscribeURL to confirm the SNS subscription.
(ctx context.Context, client *http.Client, url string)
| 86 | // confirmSubscription GETs the (already host-allow-listed) SubscribeURL to |
| 87 | // confirm the SNS subscription. |
| 88 | func confirmSubscription(ctx context.Context, client *http.Client, url string) error { |
| 89 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) |
| 90 | if err != nil { |
| 91 | return err |
| 92 | } |
| 93 | resp, err := client.Do(req) |
| 94 | if err != nil { |
| 95 | return err |
| 96 | } |
| 97 | defer resp.Body.Close() |
| 98 | io.Copy(io.Discard, io.LimitReader(resp.Body, 64*1024)) |
| 99 | if resp.StatusCode < 200 || resp.StatusCode >= 300 { |
| 100 | return &httpStatusError{resp.StatusCode} |
| 101 | } |
| 102 | return nil |
| 103 | } |
| 104 | |
| 105 | type httpStatusError struct{ code int } |
| 106 |