<commit_before>package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"net/http"

	"github.com/gorilla/mux"
)

func sendJSON(thingy interface{}, w http.ResponseWriter) {
	w.Header().Add("Content-Type", "text/json")
	w.Header().Add("Access-Control-Allow-Origin", "*")
	w.Header().Add("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS")
	err := json.NewEncoder(w).Encode(thingy)
	if err != nil {
		print("Bad JSON")
		http.Error(w, fmt.Sprintf("JSON encoding error (probably a server bug): %v", err),
			http.StatusInternalServerError)
	}
}

func readJSON(thingyPtr interface{}, w http.ResponseWriter, r *http.Request) error {
	err := json.NewDecoder(r.Body).Decode(thingyPtr)
	if err != nil {
		println("Bad input JSON")
		http.Error(w, fmt.Sprintf("JSON decoding error: %v", err),
			http.StatusInternalServerError)
		return err
	}<commit_msg>errors<commit_after>package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"net/http"

	"github.com/gorilla/mux"
)

func sendJSON(thingy interface{}, w http.ResponseWriter) {
	w.Header().Add("Content-Type", "text/json")
	w.Header().Add("Access-Control-Allow-Origin", "*")
	w.Header().Add("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS")
	err := json.NewEncoder(w).Encode(thingy)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		http.Error(w, fmt.Sprintf("JSON encoding error (probably a server bug): %v", err),
			http.StatusInternalServerError)
	}
}

func readJSON(thingyPtr interface{}, w http.ResponseWriter, r *http.Request) error {
	err := json.NewDecoder(r.Body).Decode(thingyPtr)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		http.Error(w, fmt.Sprintf("JSON decoding error: %v", err),
			http.StatusInternalServerError)
		return err
	}
{'fraction_non_alphanumeric': 0.17588817705299942, 'fraction_numerical': 0.0, 'mean_word_length': 4.843537414965986, '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': '5027285', 'n_tokens_mistral': 636, 'n_tokens_neox': 610, 'n_words': 129}