pgs-cdn.diff

· erock's pastes · raw

expires: 2025-09-13

 1diff --git a/cmd/pgs/cdn/main.go b/cmd/pgs/cdn/main.go
 2index e5d195c..6c524dc 100644
 3--- a/cmd/pgs/cdn/main.go
 4+++ b/cmd/pgs/cdn/main.go
 5@@ -14,6 +14,7 @@ import (
 6 	"github.com/picosh/pico/pkg/apps/pgs"
 7 	"github.com/picosh/pico/pkg/cache"
 8 	"github.com/picosh/pico/pkg/shared"
 9+	"github.com/prometheus/client_golang/prometheus/promhttp"
10 )
11 
12 func main() {
13@@ -52,6 +53,16 @@ type cachedHttp struct {
14 func (c *cachedHttp) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
15 	_ = c.handler.ServeHTTP(writer, req, func(w http.ResponseWriter, r *http.Request) error {
16 		url, _ := url.Parse(fullURL(r))
17+
18+		if req.URL.Path == "/_metrics" {
19+			promhttp.Handler().ServeHTTP(writer, req)
20+			return nil
21+		}
22+
23+		if req.URL.Path == "/check" {
24+			url, _ = url.Parse("https://pgs.sh/check?" + r.URL.RawQuery)
25+		}
26+
27 		c.routes.Cfg.Logger.Info("proxying request to ash.pgs.sh", "url", url.String())
28 		defaultTransport := http.DefaultTransport.(*http.Transport)
29 		newTransport := defaultTransport.Clone()