INNER CODE UNIT · Go

doGithubRequest

kluctl/kluctl · internal/ipfs-exchange-info/main.go:354

func doGithubRequest(ctx context.Context, method string, url string, body string, token string) ([]byte, error) {
	log.Infof("request: %s %s", method, url)

	req, err := http.NewRequest(method, url, strings.NewReader(body))
	if err != nil {
		log.Error("NewRequest failed: ", err)
		return nil, err
	}
	req = req.WithContext(ctx)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", fmt.Sprintf("token %s", token))

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error("Request failed: ", err)
		return nil, err
	}
	defer resp.Body.Close()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…