diff --git a/.gitignore b/.gitignore index f4d432a..5119fbc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ +sqldb-ws diff --git a/controllers/table.go b/controllers/table.go index a7fc8f4..56cfff3 100644 --- a/controllers/table.go +++ b/controllers/table.go @@ -104,12 +104,21 @@ func (t *TableController) GetAllTable() { data, err := db.Table(table).GetAssociativeArray(columns, restriction, sortkeys, dir) if err != nil { log.Error().Msg(err.Error()) - t.Data["json"] = map[string]string{"error": err.Error()} + t.Ctx.Output.SetStatus(http.StatusBadRequest) } else { t.Data["json"] = data } - t.ServeJSON() + str, err := json.Marshal(data) + if err != nil { + log.Error().Msg(err.Error()) + t.Ctx.Output.SetStatus(http.StatusBadRequest) + } + strToByte := []byte(strings.ReplaceAll(string(str), "\"\\u003cnil\\u003e\"", "null")) + t.Ctx.Output.Header("Content-Type", "application/json") + t.Ctx.Output.Body(strToByte) + t.Ctx.Output.SetStatus(http.StatusOK) db.Close() + t.Ctx.Output.Body(strToByte) } // @Title GetAllTableColumn diff --git a/sqldb-ws b/sqldb-ws deleted file mode 100755 index c757886..0000000 Binary files a/sqldb-ws and /dev/null differ