feat: simplify architecture by removing cache layer and centralizing routes
- Removed over-engineered cache system for static CV data that only changes on deployment - Extracted all route configuration to internal/routes/routes.go for better organization - Implemented rate limiting and cache control middleware for PDF endpoint protection
This commit is contained in:
@@ -221,3 +221,17 @@ func (rl *RateLimiter) cleanup() {
|
||||
rl.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// CacheControl adds cache headers to static files
|
||||
// 1 hour in development, 1 day in production
|
||||
func CacheControl(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
maxAge := "3600" // 1 hour
|
||||
if os.Getenv("GO_ENV") == "production" {
|
||||
maxAge = "86400" // 1 day
|
||||
}
|
||||
|
||||
w.Header().Set("Cache-Control", "public, max-age="+maxAge)
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user