mirror of
https://github.com/nicksherron/bashhub-server.git
synced 2025-09-05 03:44:30 +08:00
internal/server: fix null search response error
A command search with 0 results would return null and cause the client to throw an error because of invalid json. For example, "bh 'some non-existent-command'" would respond with "Sorry, an error occurred communicating with Bashhub. Response Code: 200" A zero result response now returns {} which the bashhub-client doesn't complain about.
This commit is contained in:
parent
703567f19c
commit
bc3a02bd06
1 changed files with 7 additions and 1 deletions
|
@ -294,7 +294,13 @@ func setupRouter(dbPath string, logFile string) *gin.Engine {
|
|||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.IndentedJSON(http.StatusOK, result)
|
||||
if len(result) != 0 {
|
||||
c.IndentedJSON(http.StatusOK, result)
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
}
|
||||
|
||||
} else {
|
||||
command.Uuid = c.Param("path")
|
||||
result, err := command.commandGetUUID()
|
||||
|
|
Loading…
Add table
Reference in a new issue