<commit_before>package api

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/gorilla/handlers"
	"github.com/gorilla/mux"
	"net/http"
	"time"
)

// BaseRoute a base 3dt endpoint location.
const BaseRoute string = "/system/health/v1"

type routeHandler struct {
	url                 string
	handler             func(http.ResponseWriter, *http.Request)
	headers             []header
	methods             []string
	gzip, canFlushCache bool
}

type header struct {
	name  string
	value string
}

func headerMiddleware(next http.Handler, headers []header) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setJSONContentType := true
		for _, header := range headers {
			if header.name == "Content-type" {
				setJSONContentType = false
			}
			w.Header().Add(header.name, header.value)
		}
		if setJSONContentType {
			w.Header().Add("Content-type", "application/json")
		}<commit_msg>add connection close header for every request<commit_after>package api

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/gorilla/handlers"
	"github.com/gorilla/mux"
	"net/http"
	"time"
)

// BaseRoute a base 3dt endpoint location.
const BaseRoute string = "/system/health/v1"

type routeHandler struct {
	url                 string
	handler             func(http.ResponseWriter, *http.Request)
	headers             []header
	methods             []string
	gzip, canFlushCache bool
}

type header struct {
	name  string
	value string
}

func headerMiddleware(next http.Handler, headers []header) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		r.Header.Set("Connection", "close")
		setJSONContentType := true
		for _, header := range headers {
			if header.name == "Content-type" {
				setJSONContentType = false
			}
			w.Header().Add(header.name, header.value)
		}
		if setJSONContentType {
			w.Header().Add("Content-type", "application/json")
		}
{'fraction_non_alphanumeric': 0.11621900826446281, 'fraction_numerical': 0.002066115702479339, 'mean_word_length': 3.257142857142857, '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': '5542735', 'n_tokens_mistral': 651, 'n_tokens_neox': 616, 'n_words': 148}