|
|
@ -1,6 +1,8 @@
|
|
|
|
package web
|
|
|
|
package web
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"embed"
|
|
|
|
|
|
|
|
"io/fs"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
|
@ -12,6 +14,9 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
var log = _log.WithField("at", "web addon")
|
|
|
|
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) {
|
|
|
|
func (web *WebAddon) echo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
c, err := web.upgrader.Upgrade(w, r, nil)
|
|
|
|
c, err := web.upgrader.Upgrade(w, r, nil)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -51,7 +56,13 @@ func NewWebAddon() *WebAddon {
|
|
|
|
|
|
|
|
|
|
|
|
web.serverMux = new(http.ServeMux)
|
|
|
|
web.serverMux = new(http.ServeMux)
|
|
|
|
web.serverMux.HandleFunc("/echo", web.echo)
|
|
|
|
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}
|
|
|
|
web.server = &http.Server{Addr: web.addr, Handler: web.serverMux}
|
|
|
|
log = log.WithField("in", "WebAddon")
|
|
|
|
log = log.WithField("in", "WebAddon")
|
|
|
|