diff --git a/addon/web/web.go b/addon/web/web.go index 392d541..ac8f162 100644 --- a/addon/web/web.go +++ b/addon/web/web.go @@ -1,6 +1,8 @@ package web import ( + "embed" + "io/fs" "net/http" "sync" @@ -12,6 +14,9 @@ import ( var log = _log.WithField("at", "web addon") +//go:embed client/build +var assets embed.FS + func (web *WebAddon) echo(w http.ResponseWriter, r *http.Request) { c, err := web.upgrader.Upgrade(w, r, nil) if err != nil { @@ -51,7 +56,13 @@ func NewWebAddon() *WebAddon { web.serverMux = new(http.ServeMux) web.serverMux.HandleFunc("/echo", web.echo) - web.serverMux.Handle("/", http.FileServer(http.Dir("addon/web/client/build"))) + + // web.serverMux.Handle("/", http.FileServer(http.Dir("addon/web/client/build"))) + fsys, err := fs.Sub(assets, "client/build") + if err != nil { + panic(err) + } + web.serverMux.Handle("/", http.FileServer(http.FS(fsys))) web.server = &http.Server{Addr: web.addr, Handler: web.serverMux} log = log.WithField("in", "WebAddon") diff --git a/go.mod b/go.mod index c4bc7eb..fc97630 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/lqqyt2423/go-mitmproxy -go 1.15 +go 1.16 require ( github.com/andybalholm/brotli v1.0.1