升级go version 1.16,ui文件嵌入go二进制内

This commit is contained in:
bjd
2020-12-28 16:10:47 +08:00
parent d8b55de5b5
commit b515406635
21 changed files with 225 additions and 107 deletions

View File

@@ -5,9 +5,8 @@ import (
"net/http"
"time"
"github.com/bjdgyc/anylink/pkg/utils"
"github.com/bjdgyc/anylink/base"
"github.com/bjdgyc/anylink/pkg/utils"
"github.com/gorilla/mux"
)

View File

@@ -2,6 +2,7 @@
package admin
import (
"embed"
"net/http"
"net/http/pprof"
@@ -9,11 +10,20 @@ import (
"github.com/gorilla/mux"
)
var UiPath embed.FS
// 开启服务
func StartAdmin() {
r := mux.NewRouter()
r.Use(authMiddleware)
r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)).
Name("static")
r.PathPrefix("/ui/").Handler(http.FileServer(
http.FS(UiPath),
)).Name("static")
r.HandleFunc("/base/login", Login).Name("login")
r.HandleFunc("/set/home", SetHome)
r.HandleFunc("/set/system", SetSystem)
@@ -49,8 +59,6 @@ func StartAdmin() {
r.HandleFunc("/debug/pprof", location("/debug/pprof/"))
r.PathPrefix("/debug/pprof/").HandlerFunc(pprof.Index)
r.PathPrefix("/").Handler(http.FileServer(http.Dir(base.Cfg.UiPath))).Name("static")
base.Info("Listen admin", base.Cfg.AdminAddr)
err := http.ListenAndServe(base.Cfg.AdminAddr, r)
if err != nil {