aboutsummaryrefslogtreecommitdiff
path: root/processors/request.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-07-07 22:57:31 +0530
committerBobby <[email protected]>2025-07-07 22:57:31 +0530
commit52a0248c1c81a14699b3d33ba7efe0c56bbe7477 (patch)
tree02d35fee769d518beb5dd01715e84d13ea421d51 /processors/request.go
parentb6a04140f2668a0dcae4befcd272e05b75bd14e5 (diff)
downloadimageboard-52a0248c1c81a14699b3d33ba7efe0c56bbe7477.tar.xz
imageboard-52a0248c1c81a14699b3d33ba7efe0c56bbe7477.zip
massive y2k retro overhaul with sidebar, context processors, and proper database organization
Diffstat (limited to 'processors/request.go')
-rw-r--r--processors/request.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/processors/request.go b/processors/request.go
new file mode 100644
index 0000000..f4fe8d2
--- /dev/null
+++ b/processors/request.go
@@ -0,0 +1,45 @@
+package processors
+
+import (
+ "github.com/gofiber/fiber/v2"
+)
+
+type QueryParam struct {
+ Key string
+ Value string
+}
+
+type Request struct {
+ Path string
+ Method string
+ Query []QueryParam
+ Params []QueryParam
+ QueryString string
+ IP string
+ URL string
+}
+
+func RequestContextProcessor(ctx *fiber.Ctx) error {
+ queryParams := []QueryParam{}
+ for k, v := range ctx.Queries() {
+ queryParams = append(queryParams, QueryParam{Key: k, Value: v})
+ }
+
+ routeParams := []QueryParam{}
+ for k, v := range ctx.AllParams() {
+ routeParams = append(routeParams, QueryParam{Key: k, Value: v})
+ }
+
+ request := Request{
+ Path: ctx.Path(),
+ Method: ctx.Method(),
+ Query: queryParams,
+ Params: routeParams,
+ QueryString: string(ctx.Request().URI().QueryString()),
+ IP: ctx.IP(),
+ URL: ctx.OriginalURL(),
+ }
+
+ ctx.Locals("Request", request)
+ return ctx.Next()
+}