From 2bb7e4c0e1dba2c699731edc14935fbc4300ff47 Mon Sep 17 00:00:00 2001 From: Serhii Mudryk Date: Sun, 26 Nov 2023 17:49:02 +0200 Subject: [PATCH] Formating index page --- shell2http.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell2http.go b/shell2http.go index 4250b76..451715e 100644 --- a/shell2http.go +++ b/shell2http.go @@ -269,7 +269,7 @@ func execShellCommand(appConfig Config, shell string, params []string, req *http // setupHandlers - setup http handlers func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB) ([]command, error) { resultHandlers := []command{} - indexLiHTML := "" + indexLiHTML := []string{} existsRootPath := false // map[path][http-method]handler @@ -289,7 +289,7 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB if row.httpMethod != "" { methodDesc = row.httpMethod + ": " } - indexLiHTML += fmt.Sprintf(`
  • %s%s - %s
  • `, path, methodDesc, path, html.EscapeString(cmd)) + indexLiHTML = append(indexLiHTML, fmt.Sprintf(`
  • %s%s - %s
  • `, path, methodDesc, path, html.EscapeString(cmd))) cmdsForLog[path] = append(cmdsForLog[path], cmd) handler := mwMethodOnly(getShellHandler(appConfig, shell, params, cacheTTL), row.httpMethod) @@ -322,12 +322,12 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB }, }) - indexLiHTML += fmt.Sprintf(`
  • %s
  • `, "/exit", "/exit") + indexLiHTML = append(indexLiHTML, fmt.Sprintf(`
  • %s
  • `, "/exit", "/exit")) } // -------------- if !appConfig.noIndex && !existsRootPath { - indexHTML := fmt.Sprintf(indexTmpl, version, indexLiHTML) + indexHTML := fmt.Sprintf(indexTmpl, version, strings.Join(indexLiHTML, "\n")) resultHandlers = append(resultHandlers, command{ path: "/", cmd: "index page",