mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-10 04:58:12 +08:00
升级go version 1.16,ui文件嵌入go二进制内
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user