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