<commit_before>package goberry

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"

	"github.com/EconomistDigitalSolutions/ramlapi"
	"github.com/EconomistDigitalSolutions/watchman/journal"
	"github.com/buddhamagnet/raml"
	"github.com/buddhamagnet/yaml"
	"github.com/gorilla/mux"
)

var (
	router     *mux.Router
	api        *raml.APIDefinition
	buildstamp string
	githash    string
)

// NewRouter creates a mux router, sets up
// a static handler and registers the dynamic
// routes and middleware handlers with the mux.
func NewRouter(ramlFile, build, hash string) *mux.Router {
	buildstamp = build
	githash = hash
	router = mux.NewRouter().StrictSlash(true)
	// Assemble middleware as required.
	assembleMiddleware()
	assembleRoutes(buildstamp, githash)
	return router
}

// assembleMiddleware sets up the middleware stack.
func assembleMiddleware() {
	http.Handle("/",
		JSONMiddleware(
			LoggingMiddleware(
				RecoverMiddleware(router))))
}

func assembleRoutes(build, hash string) {
	buildstamp = buildstamp
	githash = hash
	var err error

	// If bundling is enabled, read the RAML
	// from bundle.go
	if os.Getenv("BUNDLE_ASSETS") != "" {
		ramlFile := os.Getenv("RAMLFILE_NAME")

		if ramlFile == "" {
			ramlFile = "api.raml"
		}

		bundle, err := GoberryBundle.Open(ramlFile)
		if err != nil {<commit_msg>drop redundant variables<commit_after>package goberry

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"

	"github.com/EconomistDigitalSolutions/ramlapi"
	"github.com/EconomistDigitalSolutions/watchman/journal"
	"github.com/buddhamagnet/raml"
	"github.com/buddhamagnet/yaml"
	"github.com/gorilla/mux"
)

var (
	router     *mux.Router
	api        *raml.APIDefinition
	buildstamp string
	githash    string
)

// NewRouter creates a mux router, sets up
// a static handler and registers the dynamic
// routes and middleware handlers with the mux.
func NewRouter(ramlFile, build, hash string) *mux.Router {
	buildstamp = build
	githash = hash
	router = mux.NewRouter().StrictSlash(true)
	// Assemble middleware as required.
	assembleMiddleware()
	assembleRoutes(buildstamp, githash)
	return router
}

// assembleMiddleware sets up the middleware stack.
func assembleMiddleware() {
	http.Handle("/",
		JSONMiddleware(
			LoggingMiddleware(
				RecoverMiddleware(router))))
}

func assembleRoutes(build, hash string) {
	var err error

	// If bundling is enabled, read the RAML
	// from bundle.go
	if os.Getenv("BUNDLE_ASSETS") != "" {
		ramlFile := os.Getenv("RAMLFILE_NAME")

		if ramlFile == "" {
			ramlFile = "api.raml"
		}

		bundle, err := GoberryBundle.Open(ramlFile)
		if err != nil {
{'fraction_non_alphanumeric': 0.11417624521072797, 'fraction_numerical': 0.0, 'mean_word_length': 4.03082851637765, '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': '6553633', 'n_tokens_mistral': 981, 'n_tokens_neox': 938, 'n_words': 218}