update: Add JSON query support

This commit is contained in:
ngn
2024-03-21 21:52:14 +03:00
parent 67b6f22fb0
commit 787727b425
4 changed files with 36 additions and 10 deletions

View File

@ -57,8 +57,12 @@ func GETIndex(c *fiber.Ctx) error {
repo := c.Query("r")
name := c.Query("n")
exact := c.Query("e")
isjson := c.Query("j")
if repo == "" && name == "" {
if isjson == "1" {
return c.JSON(lib.Packages)
}
return c.Render("index", fiber.Map{
"last": lib.GetTimePassed(lastupdate),
"repos": lib.Repos,
@ -85,13 +89,16 @@ func GETIndex(c *fiber.Ctx) error {
}
}
if isjson == "1" {
return c.JSON(res)
}
return c.Render("index", fiber.Map{
"search": name,
"last": lib.GetTimePassed(lastupdate),
"repos": lib.Repos,
"pkgs": res,
})
}
func main(){