feat(server): allow cacheable paths to be configured in router

This commit is contained in:
2026-02-23 07:11:14 +01:00
parent 85882bae14
commit f0e8da51d0

View File

@@ -27,6 +27,7 @@ type RouterConfig struct {
Debug bool
DisableCache bool
DisableCompression bool
CacheablePaths []string
DBMonitor middleware.DBMonitor
RateLimitConfig config.RateLimitConfig
}
@@ -49,6 +50,9 @@ func NewRouter(cfg RouterConfig) http.Handler {
if !cfg.DisableCache {
cache := middleware.NewInMemoryCache()
cacheConfig := middleware.DefaultCacheConfig()
if len(cfg.CacheablePaths) > 0 {
cacheConfig.CacheablePaths = append([]string{}, cfg.CacheablePaths...)
}
router.Use(middleware.CacheMiddleware(cache, cacheConfig))
router.Use(middleware.CacheInvalidationMiddleware(cache))
}