Skip to content

Commit 7f532b5

Browse files
committed
Fixed log shell commands
1 parent 992d0cf commit 7f532b5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

shell2http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ func setupHandlers(cmdHandlers []Command, appConfig Config, cacheTTL raphanus.DB
423423

424424
// map[path][http-method]handler
425425
groupedCmd := map[string]map[string]http.HandlerFunc{}
426+
cmdsForLog := map[string][]string{}
426427

427428
for _, row := range cmdHandlers {
428429
path, cmd := row.path, row.cmd
@@ -438,6 +439,7 @@ func setupHandlers(cmdHandlers []Command, appConfig Config, cacheTTL raphanus.DB
438439
methodDesc = row.httpMethod + ": "
439440
}
440441
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span style="color: #888">- %s<span></li>`, path, methodDesc, path, html.EscapeString(cmd))
442+
cmdsForLog[path] = append(cmdsForLog[path], cmd)
441443

442444
handler := mwMethodOnly(getShellHandler(appConfig, shell, params, cacheTTL), row.httpMethod)
443445
if _, ok := groupedCmd[path]; !ok {
@@ -454,6 +456,7 @@ func setupHandlers(cmdHandlers []Command, appConfig Config, cacheTTL raphanus.DB
454456
resultHandlers = append(resultHandlers, Command{
455457
path: path,
456458
handler: handler,
459+
cmd: strings.Join(cmdsForLog[path], "; "),
457460
})
458461
}
459462

0 commit comments

Comments
 (0)