go:embed client/build

addon-dailer
liqiang 4 years ago
parent 392f3a0efc
commit 9f5ccdaf17

@ -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")

@ -1,6 +1,6 @@
module github.com/lqqyt2423/go-mitmproxy
go 1.15
go 1.16
require (
github.com/andybalholm/brotli v1.0.1

Loading…
Cancel
Save