add projects and metrics routes
This commit is contained in:
24
api/routes/projects.go
Normal file
24
api/routes/projects.go
Normal file
@ -0,0 +1,24 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/ngn13/website/api/database"
|
||||
"github.com/ngn13/website/api/util"
|
||||
)
|
||||
|
||||
func GET_Projects(c *fiber.Ctx) error {
|
||||
var (
|
||||
projects []database.Project
|
||||
project database.Project
|
||||
)
|
||||
|
||||
db := c.Locals("database").(*database.Type)
|
||||
|
||||
for db.ProjectNext(&project) {
|
||||
projects = append(projects, project)
|
||||
}
|
||||
|
||||
return util.JSON(c, 200, fiber.Map{
|
||||
"result": projects,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user