Skip to content

Commit

Permalink
Formating index page
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Nov 26, 2023
1 parent 9e3a204 commit 2bb7e4c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shell2http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -289,7 +289,7 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
if row.httpMethod != "" {
methodDesc = row.httpMethod + ": "
}
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span style="color: #888">- %s<span></li>`, path, methodDesc, path, html.EscapeString(cmd))
indexLiHTML = append(indexLiHTML, fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span style="color: #888">- %s<span></li>`, path, methodDesc, path, html.EscapeString(cmd)))
cmdsForLog[path] = append(cmdsForLog[path], cmd)

handler := mwMethodOnly(getShellHandler(appConfig, shell, params, cacheTTL), row.httpMethod)
Expand Down Expand Up @@ -322,12 +322,12 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
},
})

indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s</a></li>`, "/exit", "/exit")
indexLiHTML = append(indexLiHTML, fmt.Sprintf(`<li><a href=".%s">%s</a></li>`, "/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",
Expand Down

0 comments on commit 2bb7e4c

Please sign in to comment.