wpi
This commit is contained in:
parent
09f22af85b
commit
b477ad02be
6
main.go
6
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
|
||||
|
Loading…
Reference in New Issue
Block a user