<commit_before>package server

import (
	"fmt"
	"net/http"
)

// HTTPError is a helper to return errors on handlers
func HTTPError(w http.ResponseWriter, httpErr int, msg string, err error) {
	w.WriteHeader(httpErr)
	fmt.Fprintf(w, `{"error": "%s: %s"}`, msg, err.Error())
}

// JSONHandler adds json headers
func JSONHandler(actual http.Handler) http.HandlerFunc {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		actual.ServeHTTP(w, r)
	})
}<commit_msg>HTTPError helper now uses http.Error from net/http<commit_after>package server

import (
	"fmt"
	"net/http"
)

// HTTPError is a helper to return errors on handlers
func HTTPError(w http.ResponseWriter, httpErr int, msg string, err error) {
	msg := fmt.Sprintf(`{"error": "%s: %s"}`, msg, err.Error())
	http.Error(w, msg, httpErr)
	return
}

// JSONHandler adds json headers
func JSONHandler(actual http.Handler) http.HandlerFunc {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		actual.ServeHTTP(w, r)
	})
}
{'fraction_non_alphanumeric': 0.14869565217391303, 'fraction_numerical': 0.0017391304347826088, 'mean_word_length': 4.93298969072165, 'pattern_counts': {'":': 2, '<': 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': '6465461', 'n_tokens_mistral': 398, 'n_tokens_neox': 398, 'n_words': 105}