aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-07-12 16:04:49 +0530
committerBobby <[email protected]>2025-07-12 16:04:49 +0530
commit19049880136ceb5d2a6951946df50787b74b15d9 (patch)
tree795d1ea0b8cd260164afbd23cc23b6d90b34854b /controllers
parent14256a2964948c27b0233d46a811cecb130a580d (diff)
downloadimageboard-19049880136ceb5d2a6951946df50787b74b15d9.tar.xz
imageboard-19049880136ceb5d2a6951946df50787b74b15d9.zip
not found controller
Diffstat (limited to 'controllers')
-rw-r--r--controllers/404.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/controllers/404.go b/controllers/404.go
new file mode 100644
index 0000000..670f230
--- /dev/null
+++ b/controllers/404.go
@@ -0,0 +1,26 @@
+package controllers
+
+import (
+ "imageboard/utils/shortcuts"
+ "strings"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func NotFoundController(ctx *fiber.Ctx) error {
+ ctx.Locals("Title", "Page Not Found")
+
+ path := ctx.Path()
+
+ if strings.HasSuffix(path, ".json") {
+ return ctx.Status(fiber.StatusNotFound).JSON(fiber.Map{
+ "error": "Not Found",
+ })
+ }
+
+ if len(path) > 1 && strings.Contains(path[1:], ".") && !strings.HasSuffix(path, ".html") {
+ return ctx.SendStatus(fiber.StatusNotFound)
+ }
+
+ return shortcuts.Render(ctx, "404", nil)
+}