Skip to content

Commit

Permalink
json_block can be a string too
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Sep 1, 2022
1 parent 2da6016 commit 22d39f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controller/http_api_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ func (hc *HttpController) HandleAction(c *fiber.Ctx) error {

var jsonBlock bool
if _, ok := processRequest["json_block"]; ok {
// The node is really dumb with their APIs, it's ambiguous whether it can be a bool or a string
jsonBlock, ok = processRequest["json_block"].(bool)
if !ok {
return c.Status(fiber.StatusBadRequest).JSON(models.INVALID_REQUEST_ERR)
jsonBlockStr, ok := processRequest["json_block"].(string)
if !ok || (jsonBlockStr != "true" && jsonBlockStr != "false") {
return c.Status(fiber.StatusBadRequest).JSON(models.INVALID_REQUEST_ERR)
}
if jsonBlockStr == "true" {
jsonBlock = true
} else {
jsonBlock = false
}
}
}

Expand Down

0 comments on commit 22d39f4

Please sign in to comment.