mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-16 20:10:59 +01:00
fixed crash in api list, added filter support to api list
This commit is contained in:
@@ -44,7 +44,6 @@ func RestList(c *fiber.Ctx, conf *cfg.Config) error {
|
||||
attr := new(app.DbAttr)
|
||||
|
||||
if len(c.Body()) > 0 {
|
||||
|
||||
if err := c.BodyParser(attr); err != nil {
|
||||
return c.Status(fiber.StatusUnprocessableEntity).JSON(fiber.Map{
|
||||
"errors": err.Error(),
|
||||
@@ -54,7 +53,7 @@ func RestList(c *fiber.Ctx, conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
// get list
|
||||
entries, err := conf.DB.List(attr, false)
|
||||
entries, err := conf.DB.List(attr, attr.Fulltext)
|
||||
if err != nil {
|
||||
return JsonStatus(c, fiber.StatusForbidden,
|
||||
"Unable to list keys: "+err.Error())
|
||||
|
||||
@@ -42,6 +42,11 @@ func Runserver(conf *cfg.Config, args []string) error {
|
||||
return RestList(c, conf)
|
||||
})
|
||||
|
||||
api.Post("/", func(c *fiber.Ctx) error {
|
||||
// same thing as above but allows to supply parameters, see app.Dbattr{}
|
||||
return RestList(c, conf)
|
||||
})
|
||||
|
||||
api.Get("/:key", func(c *fiber.Ctx) error {
|
||||
return RestGet(c, conf)
|
||||
})
|
||||
@@ -78,7 +83,7 @@ func SetupServer(conf *cfg.Config) *fiber.App {
|
||||
})
|
||||
|
||||
router.Use(logger.New(logger.Config{
|
||||
Format: "${pid} ${ip}:${port} ${status} - ${method} ${path}\n",
|
||||
Format: "${pid} ${ip}:${port} ${status} - ${method} ${path}\n",
|
||||
DisableColors: true,
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user