diff options
| author | Bobby <[email protected]> | 2026-01-20 14:19:25 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-01-20 14:19:25 +0530 |
| commit | a04faab2a7c031b95e6e7553f9921c3bada2bc08 (patch) | |
| tree | 91c77399eac06aeb7417ed367123321f223bcfd7 /processors | |
| parent | 97459ee6173299aa352ac29b2a77dd8df7e3ab3d (diff) | |
| download | cafe-a04faab2a7c031b95e6e7553f9921c3bada2bc08.tar.xz cafe-a04faab2a7c031b95e6e7553f9921c3bada2bc08.zip | |
Implemented processors and add HTTPRequest and HTTPQueryParam types and Created utility functions for building request metadata.
Diffstat (limited to 'processors')
| -rw-r--r-- | processors/metadata.go | 17 | ||||
| -rw-r--r-- | processors/processors.go | 8 | ||||
| -rw-r--r-- | processors/request.go | 12 |
3 files changed, 37 insertions, 0 deletions
diff --git a/processors/metadata.go b/processors/metadata.go new file mode 100644 index 0000000..9f2fbfb --- /dev/null +++ b/processors/metadata.go @@ -0,0 +1,17 @@ +package processors + +import ( + "cafe/config" + + "github.com/gofiber/fiber/v2" +) + +const defaultTitle = "Shifoo's Cafe" + +func metadata(ctx *fiber.Ctx) error { + ctx.Locals("Title", defaultTitle) + ctx.Locals("AppName", config.Server.AppName) + ctx.Locals("AppDescription", config.Server.AppDescription) + + return ctx.Next() +} diff --git a/processors/processors.go b/processors/processors.go new file mode 100644 index 0000000..d56cbde --- /dev/null +++ b/processors/processors.go @@ -0,0 +1,8 @@ +package processors + +import "github.com/gofiber/fiber/v2" + +func Initialize(app *fiber.App) { + app.Use(metadata) + app.Use(request) +} diff --git a/processors/request.go b/processors/request.go new file mode 100644 index 0000000..f63a3dc --- /dev/null +++ b/processors/request.go @@ -0,0 +1,12 @@ +package processors + +import ( + "cafe/utils/meta" + + "github.com/gofiber/fiber/v2" +) + +func request(ctx *fiber.Ctx) error { + ctx.Locals("Request", meta.BuildRequest(ctx)) + return ctx.Next() +} |
