summaryrefslogtreecommitdiffci
path: root/internal/router/router.go
diff options
from:
to:
context:
space:
mode:
Diffstat (limited to 'internal/router/router.go')
-rw-r--r--internal/router/router.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/router/router.go b/internal/router/router.go
index 926d21a..5230e74 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -78,6 +78,7 @@ type Route interface {
TemplatesToInject() []string
SitemapInfo(supplements *Supplements) []SitemapInfo
ContentType() string
+ RateLimiter() *fiber.Handler
Render(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error)
AddMeta(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (meta []MetaField, err error)
AddLinkedData(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (ld map[string]any, err error)
@@ -267,6 +268,10 @@ func (r *Router) InitRoutes() (err error) {
return fmt.Errorf("failed to add '%s %s' route into template manager: %w", method, match, err)
}
+ if rateLimiter := route.RateLimiter(); rateLimiter != nil {
+ r.app.Use(match, *rateLimiter)
+ }
+
if route.IsTemplated() {
if _, ok := r.templatedRoutes[method]; !ok {
r.templatedRoutes[method] = make(map[string]Route)