Skip to content

Commit

Permalink
implemented list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirari04 committed Jan 11, 2024
1 parent 794ec39 commit 36dccef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions controllers/ListWebPageController copy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package controllers

import (
"ch/kirari04/videocms/inits"
"ch/kirari04/videocms/models"
"log"

"github.com/gofiber/fiber/v2"
)

func ListWebPage(c *fiber.Ctx) error {
var webPages []models.WebPage
if res := inits.DB.Find(&webPages); res.Error != nil {
log.Println("Failed to list webpages", res.Error)
return c.SendStatus(fiber.StatusInternalServerError)
}
return c.Status(fiber.StatusOK).JSON(&webPages)
}
1 change: 1 addition & 0 deletions routes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func Api() {
protectedApi.Delete("/server", middlewares.IsAdmin, controllers.DeleteServer)
protectedApi.Get("/servers", middlewares.IsAdmin, controllers.ListServers)

protectedApi.Get("/pages", middlewares.IsAdmin, controllers.ListWebPage)
protectedApi.Post("/page", middlewares.IsAdmin, controllers.CreateWebPage)
protectedApi.Put("/page", middlewares.IsAdmin, controllers.UpdateWebPage)

Expand Down

0 comments on commit 36dccef

Please sign in to comment.