<commit_before>/********************************
*** Web server API for Go     ***
*** Code is under MIT license ***
*** Code by CodingFerret      ***
*** github.com/squiidz        ***
*********************************/

package furserv

import (
	"fmt"
	"log"
	"net/http"
)

// Simple Server structure for a web server.
type Server struct {
	Host string
	Port string
	Log  bool
	Mux  *http.ServeMux
}

// Create a NewServer instance with the given value.
// Host: "localhost"
// Port: ":8080"
// Log: true/false
// Options: functions to run on the server instance who's gonna be return.
func NewServer(host string, port string, log bool, options ...func(s *Server)) *Server {
	svr := Server{host, port, log, http.NewServeMux()}
	for _, option := range options {
		option(&svr)
	}
	return &svr
}

// Start Listening on host and port of the Server.
// Log the request if the log was initiated as true in NewServer.
func (s *Server) Start() {
	fmt.Printf("[+] Server Running on %s ... \n", s.Port)
	if s.Log {
		http.ListenAndServe(s.Host+s.Port, s.logger(s.Mux))
	}
	http.ListenAndServe(s.Host+s.Port, s.Mux)
}

// Add function with the right sigature to the Server Mux
// and chain the provided middlewares on it.
func (s *Server) AddHandler(pat string, f func(rw http.ResponseWriter, req *http.Request), middles ...func(next http.Handler) http.Handler) {
	var stack http.Handler
	for i := len(middles) - 1; i >= 0; i-- {
		if i == len(middles)-1 {
			stack = middles[i](http.HandlerFunc(f))
		} else {
			stack = middles[i](stack)
		}
	}
	s.Mux.Handle(pat, stack)
}

// Log request received by the Server.
func (s *Server) logger(mux http.Handler) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		log.Printf("%s %s %s", req.RemoteAddr, req.Method, req.URL)
		mux.ServeHTTP(rw, req)
	})
}<commit_msg>Minor Modification<commit_after>/********************************
*** Web server API for Go     ***
*** Code is under MIT license ***
*** Code by CodingFerret      ***
*** github.com/squiidz        ***
*********************************/

package furserv

import (
	"fmt"
	"log"
	"net/http"
)

// Simple Server structure for a web server.
type Server struct {
	Host string
	Port string
	Log  bool
	Mux  *http.ServeMux
}

// Create a NewServer instance with the given value.
// Host: "localhost"
// Port: ":8080"
// Log: true/false
// Options: functions to run on the server instance who's gonna be return.
func NewServer(host string, port string, log bool, options ...func(s *Server)) *Server {
	svr := Server{host, port, log, http.NewServeMux()}
	for _, option := range options {
		option(&svr)
	}
	return &svr
}

// Start Listening on host and port of the Server.
// Log the request if the log was initiated as true in NewServer.
func (s *Server) Start() {
	fmt.Printf("[+] Server Running on %s ... \n", s.Port)
	if s.Log {
		http.ListenAndServe(s.Host+s.Port, s.logger(s.Mux))
	}
	http.ListenAndServe(s.Host+s.Port, s.Mux)
}

// Add function with the right sigature to the Server Mux
// and chain the provided middlewares on it.
func (s *Server) AddRoute(pat string, f func(rw http.ResponseWriter, req *http.Request), middles ...func(next http.Handler) http.Handler) {
	var stack http.Handler
	for i := len(middles) - 1; i >= 0; i-- {
		if i == len(middles)-1 {
			stack = middles[i](http.HandlerFunc(f))
		} else {
			stack = middles[i](stack)
		}
	}
	s.Mux.Handle(pat, stack)
}

// Log request received by the Server.
func (s *Server) logger(mux http.Handler) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		log.Printf("%s %s %s", req.RemoteAddr, req.Method, req.URL)
		mux.ServeHTTP(rw, req)
	})
}
{'fraction_non_alphanumeric': 0.17728381675250746, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 3.5781637717121586, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4682916', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1264, 'n_words': 407}