update: Add JSON query support
This commit is contained in:
9
main.go
9
main.go
@ -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(){
|
||||
|
Reference in New Issue
Block a user