<commit_before>package main

import (
	"fmt"
	"net/http"
	"os"
	"strconv"
	"strings"

	"github.com/gorilla/mux"
	consul "github.com/hashicorp/consul/api"
	nomad "github.com/hashicorp/nomad/api"
	"github.com/jippi/hashi-ui/backend/config"
	consul_helper "github.com/jippi/hashi-ui/backend/consul/helper"
	nomad_helper "github.com/jippi/hashi-ui/backend/nomad/helper"
	newrelic "github.com/newrelic/go-agent"
	log "github.com/sirupsen/logrus"
)

var (
	GitCommit string // Filled in by the compiler
	AppConfig *config.Config
)

func startLogging(logLevel string) {
	level, err := log.ParseLevel(logLevel)
	if err != nil {
		fmt.Printf("%s (%s)", err, logLevel)
		os.Exit(1)
	}

	log.SetLevel(level)
}

func main() {
	cfg := config.DefaultConfig()
	cfg.Parse()

	AppConfig = cfg

	startLogging(cfg.LogLevel)

	log.Infof("----------------------------------------------------------------------------------")
	log.Infof("|                                 HASHI UI                                       |")
	log.Infof("----------------------------------------------------------------------------------")
	if !cfg.HttpsEnable {
		log.Infof("| listen-address            : http://%-43s |", cfg.ListenAddress)
	} else {
		log.Infof("| listen-address            : https://%-43s  |", cfg.ListenAddress)
	}
	log.Infof("| server-certificate        : %-50s |", cfg.ServerCert)
	log.Infof("| server-key       	       : %-50s |", cfg.ServerKey)
	log.Infof("| site-title       	       : %-50s |", cfg.SiteTitle)
	log.Infof("| proxy-address   	       : %-50s |", cfg.ProxyAddress)
	log.Infof("| log-level       	       : %-50s |", cfg.LogLevel)
	log.Infof("| new-relic-enable  	       : %-50v |", cfg.NewRelicEnable)
	log.Infof("| new-relic-app-name	       : %-50s |", cfg.NewRelicAppName)

	if cfg.ThrottleUpdateDuration != nil {
		log.Infof("| throttle-update-duration  : %-50s |", cfg.ThrottleUpdateDuration)
	} else {
		log.Infof("| throttle-update-duration  : %-50s |", "0s")
	}

	// Nomad
	log.Infof("| nomad-enable     	       : %-50t |", cfg.NomadEnable)
	if cfg.NomadReadOnly {
		log.Infof("| nomad-read-only           : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-read-only           : %-50s |", "No (Hashi-UI can change Nomad state)")
	}
	log.Infof("| nomad-address             : %-50s |", cfg.NomadAddress)
	log.Infof("| nomad-acl-token           : %-50s |", cfg.NomadACLToken)
	log.Infof("| nomad-ca-cert             : %-50s |", cfg.NomadCACert)
	log.Infof("| nomad-client-cert         : %-50s |", cfg.NomadClientCert)
	log.Infof("| nomad-client-key          : %-50s |", cfg.NomadClientKey)
	log.Infof("| nomad-skip-verify         : %-50t |", cfg.NomadSkipVerify)
	log.Infof("| nomad-hide-env-data       : %-50v |", cfg.NomadHideEnvData)
	if cfg.NomadSkipVerify {
		log.Infof("| nomad-skip-verify         : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-skip-verify         : %-50s |", "No")
	}
	if cfg.NomadAllowStale {
		log.Infof("| nomad-allow-stale         : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-allow-stale         : %-50s |", "No")
	}
	log.Infof("| nomad-color               : %-50s |", cfg.NomadColor)

	// Consul
	log.Infof("| consul-enable     	       : %-50t |", cfg.ConsulEnable)
	if cfg.ConsulReadOnly {
		log.Infof("| consul-read-only          : %-50s |", "Yes")
	} else {
		log.Infof("| consul-read-only          : %-50s |", "No (Hashi-UI can change Consul state)")
	}
	log.Infof("| consul-address            : %-50s |", cfg.ConsulAddress)
	log.Infof("| consul-acl-token          : %-<PASSWORD> |", cfg.ConsulACLToken)
	log.Infof("| consul-color              : %-50s |", cfg.ConsulColor)

	log.Infof("----------------------------------------------------------------------------------")
	log.Infof("")

	if !cfg.NomadEnable && !cfg.ConsulEnable {
		log.Fatal("Please enable at least Consul (--consul-enable) or Nomad (--nomad-enable)")
	}

	myAssetFS := assetFS()
	router := mux.NewRouter().PathPrefix(cfg.ProxyPath).Subrouter()<commit_msg>Revert "Fix proxied websocket routing"<commit_after>package main

import (
	"fmt"
	"net/http"
	"os"
	"strconv"
	"strings"

	"github.com/gorilla/mux"
	consul "github.com/hashicorp/consul/api"
	nomad "github.com/hashicorp/nomad/api"
	"github.com/jippi/hashi-ui/backend/config"
	consul_helper "github.com/jippi/hashi-ui/backend/consul/helper"
	nomad_helper "github.com/jippi/hashi-ui/backend/nomad/helper"
	newrelic "github.com/newrelic/go-agent"
	log "github.com/sirupsen/logrus"
)

var (
	GitCommit string // Filled in by the compiler
	AppConfig *config.Config
)

func startLogging(logLevel string) {
	level, err := log.ParseLevel(logLevel)
	if err != nil {
		fmt.Printf("%s (%s)", err, logLevel)
		os.Exit(1)
	}

	log.SetLevel(level)
}

func main() {
	cfg := config.DefaultConfig()
	cfg.Parse()

	AppConfig = cfg

	startLogging(cfg.LogLevel)

	log.Infof("----------------------------------------------------------------------------------")
	log.Infof("|                                 HASHI UI                                       |")
	log.Infof("----------------------------------------------------------------------------------")
	if !cfg.HttpsEnable {
		log.Infof("| listen-address            : http://%-43s |", cfg.ListenAddress)
	} else {
		log.Infof("| listen-address            : https://%-43s  |", cfg.ListenAddress)
	}
	log.Infof("| server-certificate        : %-50s |", cfg.ServerCert)
	log.Infof("| server-key       	       : %-50s |", cfg.ServerKey)
	log.Infof("| site-title       	       : %-50s |", cfg.SiteTitle)
	log.Infof("| proxy-address   	       : %-50s |", cfg.ProxyAddress)
	log.Infof("| log-level       	       : %-50s |", cfg.LogLevel)
	log.Infof("| new-relic-enable  	       : %-50v |", cfg.NewRelicEnable)
	log.Infof("| new-relic-app-name	       : %-50s |", cfg.NewRelicAppName)

	if cfg.ThrottleUpdateDuration != nil {
		log.Infof("| throttle-update-duration  : %-50s |", cfg.ThrottleUpdateDuration)
	} else {
		log.Infof("| throttle-update-duration  : %-50s |", "0s")
	}

	// Nomad
	log.Infof("| nomad-enable     	       : %-50t |", cfg.NomadEnable)
	if cfg.NomadReadOnly {
		log.Infof("| nomad-read-only           : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-read-only           : %-50s |", "No (Hashi-UI can change Nomad state)")
	}
	log.Infof("| nomad-address             : %-50s |", cfg.NomadAddress)
	log.Infof("| nomad-acl-token           : %-50s |", cfg.NomadACLToken)
	log.Infof("| nomad-ca-cert             : %-50s |", cfg.NomadCACert)
	log.Infof("| nomad-client-cert         : %-50s |", cfg.NomadClientCert)
	log.Infof("| nomad-client-key          : %-50s |", cfg.NomadClientKey)
	log.Infof("| nomad-skip-verify         : %-50t |", cfg.NomadSkipVerify)
	log.Infof("| nomad-hide-env-data       : %-50v |", cfg.NomadHideEnvData)
	if cfg.NomadSkipVerify {
		log.Infof("| nomad-skip-verify         : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-skip-verify         : %-50s |", "No")
	}
	if cfg.NomadAllowStale {
		log.Infof("| nomad-allow-stale         : %-50s |", "Yes")
	} else {
		log.Infof("| nomad-allow-stale         : %-50s |", "No")
	}
	log.Infof("| nomad-color               : %-50s |", cfg.NomadColor)

	// Consul
	log.Infof("| consul-enable     	       : %-50t |", cfg.ConsulEnable)
	if cfg.ConsulReadOnly {
		log.Infof("| consul-read-only          : %-50s |", "Yes")
	} else {
		log.Infof("| consul-read-only          : %-50s |", "No (Hashi-UI can change Consul state)")
	}
	log.Infof("| consul-address            : %-50s |", cfg.ConsulAddress)
	log.Infof("| consul-acl-token          : %-50s |", cfg.ConsulACLToken)
	log.Infof("| consul-color              : %-50s |", cfg.ConsulColor)

	log.Infof("----------------------------------------------------------------------------------")
	log.Infof("")

	if !cfg.NomadEnable && !cfg.ConsulEnable {
		log.Fatal("Please enable at least Consul (--consul-enable) or Nomad (--nomad-enable)")
	}

	myAssetFS := assetFS()
	router := mux.NewRouter()
{'fraction_non_alphanumeric': 0.2346319251201619, 'fraction_numerical': 0.016443207690361752, 'mean_word_length': 2.01793893129771, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1404388', 'n_tokens_mistral': 3109, 'n_tokens_neox': 2967, 'n_words': 477}