repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
47f9490
parent
4ee7ba6
author
Eric Bower
date
2026-04-19 12:02:29 -0400 EDT
feat(httpcache): ignore routes cfg
2 files changed,  +15, -4
M pkg/apps/pgs/web.go
+1, -0
1@@ -120,6 +120,7 @@ func NewPgsHttpCache(cfg *PgsConfig, upstream http.Handler) *httpcache.HttpCache
2 			TxtPrefix: cfg.TxtPrefix,
3 		},
4 		CacheMetrics: metrics,
5+		IgnoreRoutes: []string{"/check", "/_metrics"},
6 	}
7 	httpCache.Logger.Info("httpcache initiated", "ttl", httpCache.Ttl, "storage", "lru")
8 	return httpCache
M pkg/httpcache/serve.go
+14, -4
 1@@ -45,10 +45,11 @@ func (p *DefaultCacheMetrics) AddUpstreamRequest()  {}
 2 type HttpCache struct {
 3 	CacheKey
 4 	CacheMetrics
 5-	Ttl      time.Duration
 6-	Upstream http.Handler
 7-	Cache    Cacher
 8-	Logger   *slog.Logger
 9+	Ttl          time.Duration
10+	Upstream     http.Handler
11+	Cache        Cacher
12+	Logger       *slog.Logger
13+	IgnoreRoutes []string
14 }
15 
16 func NewHttpCache(log *slog.Logger, upstream http.Handler) *HttpCache {
17@@ -71,6 +72,15 @@ func (c *HttpCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
18 		http.Error(w, "upstream http handler not found", http.StatusNotFound)
19 		return
20 	}
21+
22+	reqUri := r.URL.RequestURI()
23+	for _, uri := range c.IgnoreRoutes {
24+		if uri == reqUri {
25+			c.Upstream.ServeHTTP(w, r)
26+			return
27+		}
28+	}
29+
30 	cacheKey := c.GetCacheKey(r)
31 	log := c.Logger.With("cache_key", cacheKey)
32