2023-04-27 19:03:28 +02:00
|
|
|
package web
|
|
|
|
|
2023-04-28 18:24:09 +02:00
|
|
|
import (
|
|
|
|
"codeberg.org/lauralani/go-urlsh/models"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
2023-04-27 19:03:28 +02:00
|
|
|
|
2023-04-28 23:39:02 +02:00
|
|
|
func HandleAdminLinkNewGet(c *fiber.Ctx) error {
|
2023-04-27 19:03:28 +02:00
|
|
|
return c.Render("add_link", nil)
|
|
|
|
}
|
2023-04-28 18:24:09 +02:00
|
|
|
|
|
|
|
func HandleAdminLinkIndexGet(c *fiber.Ctx) error {
|
|
|
|
var links []models.Link
|
|
|
|
|
|
|
|
err := models.DB.NewSelect().Model(&links).Scan(context.Background())
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error querying links: %v", err.Error())
|
|
|
|
}
|
|
|
|
return c.Render("links", links)
|
|
|
|
}
|