MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / createHTTPRequest

Method createHTTPRequest

lib/email/chime/client.go:223–238  ·  view source on GitHub ↗
(ctx context.Context, body []byte)

Source from the content-addressed store, hash-verified

221}
222
223func (s *Sender) createHTTPRequest(ctx context.Context, body []byte) (*http.Request, error) {
224 apiURL := fmt.Sprintf("%s/v1/notifytargetsync", s.baseURL)
225 req, err := http.NewRequestWithContext(ctx, http.MethodPost, apiURL, bytes.NewBuffer(body))
226 if err != nil {
227 return nil, fmt.Errorf("%w: failed to create HTTP request: %w", ErrPermanentSystem, err)
228 }
229
230 token, err := s.tokenSource.Token()
231 if err != nil {
232 return nil, fmt.Errorf("%w: failed to retrieve access token: %w", ErrPermanentSystem, err)
233 }
234 req.Header.Set("Authorization", "Bearer "+token.AccessToken)
235 req.Header.Set("Content-Type", "application/json")
236
237 return req, nil
238}
239
240func (s *Sender) executeRequest(req *http.Request) (*http.Response, []byte, error) {
241 resp, err := s.httpClient.Do(req)

Callers 1

SendMethod · 0.95

Calls 1

TokenMethod · 0.80

Tested by

no test coverage detected