From 9af209ca75828ef7dd310a16241d0643b3cd4f4d Mon Sep 17 00:00:00 2001 From: wlkjyy Date: Mon, 20 May 2024 15:39:31 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 5f42d0e..8a2301b 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ var port = flag.String("port", "6080", "port") // var port = "6080" var host = flag.String("host", "127.0.0.1:2735", "host") -var local_path = flag.String("local_path", "/root/apiserver/console_agent", "local_path") +var localPath = flag.String("local_path", "/root/apiserver/console_agent", "local_path") var contextPath = "/" @@ -38,9 +38,9 @@ func main() { // } http.Handle(contextPath+"/exec/", websocket.Handler(ExecContainer)) - http_dir := http.FileServer(http.Dir(*local_path)) - http.Handle(contextPath+"/", http_dir) - // 仅index.html + http_dir := http.FileServer(http.Dir(*localPath)) + http.Handle(contextPath+"/", http.StripPrefix("/console/", http_dir)) + // 仅index.html if err := http.ListenAndServe(":"+*port, nil); err != nil { panic(err) @@ -48,9 +48,9 @@ func main() { } func getContainerIdByToken(token string) string { -// file, err := os.Open(".token") - token_file := *local_path + "/.token" - file, err := os.Open(token_file) + // file, err := os.Open(".token") + tokenFile := *localPath + "/.token" + file, err := os.Open(tokenFile) if err != nil { return "" }