From b477ad02bec958057f1acde3e90e284467cf4d73 Mon Sep 17 00:00:00 2001 From: simonpetit Date: Mon, 6 Jan 2025 17:00:50 +0000 Subject: [PATCH] wpi --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index bf337e7..8b5ec31 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,9 @@ func main() { // Parse the API URL - r.Handle("/cats/*", reverseProxy("https://catfact.ninja")) + r.Handle("/cats/*", reverseProxy("https://catfact.ninja", "/cats")) - r.Handle("/coins/*", reverseProxy("https://api.coindesk.com/v1/bpi")) + r.Handle("/coins/*", reverseProxy("https://api.coindesk.com/v1/bpi", "/coins")) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("root.")) @@ -46,7 +46,7 @@ func reverseProxy(target string, prefixToStrip string) http.Handler { // Rewrite the request path by stripping the prefix originalPath := r.URL.Path strippedPath := strings.TrimPrefix(originalPath, prefixToStrip) - + log.Printf("stripped path %s", strippedPath) // Update the proxied request URL r.URL.Path = strippedPath // Use the stripped path in the proxy r.URL.Scheme = parsedURL.Scheme