<commit_before>package main

import (
	"flag"
	"fmt"
	"github.com/elazarl/goproxy"
	"log"
	"net/http"
	"strings"
)

var (
	endpoint = flag.String("e", "", "Docker d endpoint.")
	verbose  = flag.Bool("v", false, "Verbose logging.")
	port     = flag.String("p", "9000", "Port to serve dockerui.")
)

type multiHandler struct {
	base    http.Handler
	proxy   *goproxy.ProxyHttpServer
	verbose bool
}

func (h *multiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if h.verbose {
		log.Printf("%s: %s\n", r.Method, r.URL.String())
	}
	if isDockerRequest(r.URL.String()) {
		h.proxy.ServeHTTP(w, r)
	} else {
		h.base.ServeHTTP(w, r)
	}
}

func isDockerRequest(url string) bool {
	return strings.Contains(url, "dockerapi/")
}

func createHandler(dir string) http.Handler {
	fileHandler := http.FileServer(http.Dir(dir))
	proxy := goproxy.NewProxyHttpServer()
	proxy.Verbose = *verbose

	proxy.OnRequest().DoFunc(func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
		c := http.Client{}
		path := strings.Replace(r.URL.RequestURI(), "dockerapi/", "", -1)
		n, err := http.NewRequest(r.Method, *endpoint+path, r.Body)
		n.Header = r.Header

		if err != nil {
			log.Fatal(err)
		}
		resp, err := c.Do(n)
		if err != nil {
			log.Fatal(err)
		}
		return r, resp

	})
	return &multiHandler{base: fileHandler, proxy: proxy, verbose: *verbose}
}

func main() {
	flag.Parse()

	path := fmt.Sprintf(":%s", *port)

	handler := createHandler("/app")

	log.Fatal(http.ListenAndServe(path, handler))
}<commit_msg>Allows to specify the path to the assets<commit_after>package main

import (
	"flag"
	"fmt"
	"github.com/elazarl/goproxy"
	"log"
	"net/http"
	"strings"
)

var (
	endpoint = flag.String("e", "", "Docker d endpoint.")
	verbose  = flag.Bool("v", false, "Verbose logging.")
	port     = flag.String("p", "9000", "Port to serve dockerui.")
	assets   = flag.String("-a", "/app", "Path to the assets.")
)

type multiHandler struct {
	base    http.Handler
	proxy   *goproxy.ProxyHttpServer
	verbose bool
}

func (h *multiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if h.verbose {
		log.Printf("%s: %s\n", r.Method, r.URL.String())
	}
	if isDockerRequest(r.URL.String()) {
		h.proxy.ServeHTTP(w, r)
	} else {
		h.base.ServeHTTP(w, r)
	}
}

func isDockerRequest(url string) bool {
	return strings.Contains(url, "dockerapi/")
}

func createHandler(dir string) http.Handler {
	fileHandler := http.FileServer(http.Dir(dir))
	proxy := goproxy.NewProxyHttpServer()
	proxy.Verbose = *verbose

	proxy.OnRequest().DoFunc(func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
		c := http.Client{}
		path := strings.Replace(r.URL.RequestURI(), "dockerapi/", "", -1)
		n, err := http.NewRequest(r.Method, *endpoint+path, r.Body)
		n.Header = r.Header

		if err != nil {
			log.Fatal(err)
		}
		resp, err := c.Do(n)
		if err != nil {
			log.Fatal(err)
		}
		return r, resp

	})
	return &multiHandler{base: fileHandler, proxy: proxy, verbose: *verbose}
}

func main() {
	flag.Parse()

	handler := createHandler(*assets)

	path := fmt.Sprintf(":%s", *port)
	log.Fatal(http.ListenAndServe(path, handler))
}
{'fraction_non_alphanumeric': 0.17447751741608614, 'fraction_numerical': 0.0031665611146295125, 'mean_word_length': 3.990521327014218, 'pattern_counts': {'":': 2, '<': 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': '592754', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1200, 'n_words': 260}