<commit_before>package webircgateway

import (
	"crypto/tls"
	"encoding/json"
	"fmt"
	"net/http"

	"errors"

	"github.com/kiwiirc/webircgateway/pkg/identd"
	"rsc.io/letsencrypt"
)

var (
	// Version - The current version of webircgateway
	Version    = "-"
	identdServ identd.Server
	HttpRouter *http.ServeMux
	LogOutput  chan string
)

func init() {
	HttpRouter = http.NewServeMux()
	LogOutput = make(chan string, 5)
}

func Prepare() {
	maybeStartStaticFileServer()
	initHttpRoutes()
	maybeStartIdentd()
}

func maybeStartIdentd() {
	identdServ = identd.NewIdentdServer()

	if Config.Identd {
		err := identdServ.Run()
		if err != nil {
			logOut(3, "Error starting identd server: %s", err.Error())
		} else {
			logOut(2, "Identd server started")
		}
	}
}

func maybeStartStaticFileServer() {
	if Config.Webroot != "" {
		webroot := ConfigResolvePath(Config.Webroot)
		logOut(2, "Serving files from %s", webroot)
		http.Handle("/", http.FileServer(http.Dir(webroot)))
	}
}

func initHttpRoutes() error {
	// Add all the transport routes
	engineConfigured := false
	for _, serverEngine := range Config.ServerEngines {
		switch serverEngine {
		case "kiwiirc":
			kiwiircHTTPHandler(HttpRouter)
			engineConfigured = true
		case "websocket":
			websocketHTTPHandler(HttpRouter)
			engineConfigured = true
		case "sockjs":
			sockjsHTTPHandler(HttpRouter)
			engineConfigured = true
		default:
			logOut(3, "Invalid server engine: '%s'", serverEngine)
		}
	}

	if !engineConfigured {
		logOut(3, "No server engines configured")
		return errors.New("No server engines configured")
	}
<commit_msg>Static file serviing with the public http interface<commit_after>package webircgateway

import (
	"crypto/tls"
	"encoding/json"
	"fmt"
	"net/http"

	"errors"

	"github.com/kiwiirc/webircgateway/pkg/identd"
	"rsc.io/letsencrypt"
)

var (
	// Version - The current version of webircgateway
	Version    = "-"
	identdServ identd.Server
	HttpRouter *http.ServeMux
	LogOutput  chan string
)

func init() {
	HttpRouter = http.NewServeMux()
	LogOutput = make(chan string, 5)
}

func Prepare() {
	maybeStartStaticFileServer()
	initHttpRoutes()
	maybeStartIdentd()
}

func maybeStartIdentd() {
	identdServ = identd.NewIdentdServer()

	if Config.Identd {
		err := identdServ.Run()
		if err != nil {
			logOut(3, "Error starting identd server: %s", err.Error())
		} else {
			logOut(2, "Identd server started")
		}
	}
}

func maybeStartStaticFileServer() {
	if Config.Webroot != "" {
		webroot := ConfigResolvePath(Config.Webroot)
		logOut(2, "Serving files from %s", webroot)
		HttpRouter.Handle("/", http.FileServer(http.Dir(webroot)))
	}
}

func initHttpRoutes() error {
	// Add all the transport routes
	engineConfigured := false
	for _, serverEngine := range Config.ServerEngines {
		switch serverEngine {
		case "kiwiirc":
			kiwiircHTTPHandler(HttpRouter)
			engineConfigured = true
		case "websocket":
			websocketHTTPHandler(HttpRouter)
			engineConfigured = true
		case "sockjs":
			sockjsHTTPHandler(HttpRouter)
			engineConfigured = true
		default:
			logOut(3, "Invalid server engine: '%s'", serverEngine)
		}
	}

	if !engineConfigured {
		logOut(3, "No server engines configured")
		return errors.New("No server engines configured")
	}

{'fraction_non_alphanumeric': 0.12004950495049505, 'fraction_numerical': 0.0037128712871287127, 'mean_word_length': 4.282679738562091, 'pattern_counts': {'":': 6, '<': 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': '3923454', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1128, 'n_words': 257}