2024-08-21 23:43:54 +02:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
2024-08-22 15:15:16 +02:00
|
|
|
log "git.tijl.dev/tijl/tijl.dev-core/modules/logger"
|
2024-08-21 23:43:54 +02:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var commons *fiber.Map = &fiber.Map{}
|
|
|
|
var commonFunctions []func(*fiber.Ctx, *fiber.Map)
|
|
|
|
|
|
|
|
func RegisterCommon(function func(*fiber.Ctx, *fiber.Map)) {
|
2024-08-22 13:47:16 +02:00
|
|
|
log.Debug().Msg("web.RegisterCommon: registered a function")
|
2024-08-21 23:43:54 +02:00
|
|
|
commonFunctions = append(commonFunctions, function)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Common(c *fiber.Ctx) *fiber.Map {
|
|
|
|
theMap := &fiber.Map{}
|
|
|
|
for _, function := range commonFunctions {
|
|
|
|
function(c, theMap)
|
|
|
|
}
|
|
|
|
return theMap
|
|
|
|
}
|