Skip to content

Commit 2bb7e4c

Browse files
committed
Formating index page
1 parent 9e3a204 commit 2bb7e4c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shell2http.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func execShellCommand(appConfig Config, shell string, params []string, req *http
269269
// setupHandlers - setup http handlers
270270
func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB) ([]command, error) {
271271
resultHandlers := []command{}
272-
indexLiHTML := ""
272+
indexLiHTML := []string{}
273273
existsRootPath := false
274274

275275
// map[path][http-method]handler
@@ -289,7 +289,7 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
289289
if row.httpMethod != "" {
290290
methodDesc = row.httpMethod + ": "
291291
}
292-
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span style="color: #888">- %s<span></li>`, path, methodDesc, path, html.EscapeString(cmd))
292+
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)))
293293
cmdsForLog[path] = append(cmdsForLog[path], cmd)
294294

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

325-
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s</a></li>`, "/exit", "/exit")
325+
indexLiHTML = append(indexLiHTML, fmt.Sprintf(`<li><a href=".%s">%s</a></li>`, "/exit", "/exit"))
326326
}
327327

328328
// --------------
329329
if !appConfig.noIndex && !existsRootPath {
330-
indexHTML := fmt.Sprintf(indexTmpl, version, indexLiHTML)
330+
indexHTML := fmt.Sprintf(indexTmpl, version, strings.Join(indexLiHTML, "\n"))
331331
resultHandlers = append(resultHandlers, command{
332332
path: "/",
333333
cmd: "index page",

0 commit comments

Comments
 (0)