<commit_before>package promclient

import (
	"context"
	"encoding/json"
	"net/http"

	"github.com/jacksontj/promxy/promhttputil"
	"github.com/prometheus/common/model"
)

func DoRequest(ctx context.Context, url string, client *http.Client, responseStruct interface{}) error {
	// Create request
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return err
	}

	// Pass the context on
	req.WithContext(ctx)

	// Send the request
	resp, err := client.Do(req)
	if err != nil {
		return err
	}

	// TODO: check content headers? Prom seems to only do JSON so not necessary
	// for now
	if err := json.NewDecoder(resp.Body).Decode(responseStruct); err != nil {
		return err
	}

	return nil<commit_msg>Actually pass the context on<commit_after>package promclient

import (
	"context"
	"encoding/json"
	"net/http"

	"github.com/jacksontj/promxy/promhttputil"
	"github.com/prometheus/common/model"
)

func DoRequest(ctx context.Context, url string, client *http.Client, responseStruct interface{}) error {
	// Create request
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return err
	}

	// Pass the context on
	req = req.WithContext(ctx)

	// Send the request
	resp, err := client.Do(req)
	if err != nil {
		return err
	}

	// TODO: check content headers? Prom seems to only do JSON so not necessary
	// for now
	if err := json.NewDecoder(resp.Body).Decode(responseStruct); err != nil {
		return err
	}

	return nil
{'fraction_non_alphanumeric': 0.12439193884642112, 'fraction_numerical': 0.0, 'mean_word_length': 3.6905537459283386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3177690', 'n_tokens_mistral': 500, 'n_tokens_neox': 480, 'n_words': 144}