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 "" }