index endpoint start

This commit is contained in:
Simon Martens
2024-11-16 02:30:20 +01:00
parent d4feb20f07
commit 527fbfa000
14 changed files with 230 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
package controller
package controllers
import (
"net/http"

21
controllers/years.go Normal file
View File

@@ -0,0 +1,21 @@
package controllers
import (
"github.com/Theodor-Springmann-Stiftung/kgpz_web/app"
"github.com/gofiber/fiber/v2"
)
func GetYear(kgpz *app.KGPZ) fiber.Handler {
return func(c *fiber.Ctx) error {
y := c.Params("year", "1764")
if len(y) != 4 {
return c.SendStatus(fiber.StatusBadRequest)
}
issues := kgpz.Library.Issues.GetYear(y)
if len(issues.Issues) == 0 {
return c.SendStatus(fiber.StatusNotFound)
}
return c.Render("/", fiber.Map{"model": issues})
}
}