diff --git a/blockstore_proxy.go b/blockstore_proxy.go index 6421d9b..ce2cc32 100644 --- a/blockstore_proxy.go +++ b/blockstore_proxy.go @@ -24,8 +24,6 @@ import ( const ( EnvProxyGateway = "PROXY_GATEWAY_URL" - - DefaultKuboRPC = "http://127.0.0.1:5001" ) type proxyBlockStore struct { diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 3664fa2..09ee5a6 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -26,10 +26,9 @@ ### `KUBO_RPC_URL` -Default: see `DefaultKuboRPC` - Single URL or a comma separated list of RPC endpoints that provide `/api/v0` from Kubo. This is used to redirect legacy `/api/v0` commands that need to be handled on `ipfs.io`. +If this is not set, the redirects are not set up. ### `BLOCK_CACHE_SIZE` diff --git a/handlers.go b/handlers.go index d49795a..5eb2ccb 100644 --- a/handlers.go +++ b/handlers.go @@ -163,10 +163,13 @@ func makeGatewayHandler(bs bstore.Blockstore, kuboRPC, gatewayURLs []string, por mux := http.NewServeMux() mux.Handle("/ipfs/", ipfsHandler) mux.Handle("/ipns/", ipnsHandler) - // TODO: below is legacy which we want to remove, measuring this separately - // allows us to decide when is the time to do it. - legacyKuboRpcHandler := withHTTPMetrics(newKuboRPCHandler(kuboRPC), "legacyKuboRpc") - mux.Handle("/api/v0/", legacyKuboRpcHandler) + + if len(kuboRPC) != 0 { + // TODO: below is legacy which we want to remove, measuring this separately + // allows us to decide when is the time to do it. + legacyKuboRpcHandler := withHTTPMetrics(newKuboRPCHandler(kuboRPC), "legacyKuboRpc") + mux.Handle("/api/v0/", legacyKuboRpcHandler) + } // Construct the HTTP handler for the gateway. handler := withConnect(mux) diff --git a/main.go b/main.go index 32906a5..884d9af 100644 --- a/main.go +++ b/main.go @@ -58,7 +58,7 @@ See documentation at: https://github.com/ipfs/bifrost-gateway/#readme`, // Get env variables. saturnOrchestrator := getEnv(EnvSaturnOrchestrator, "") proxyGateway := getEnvs(EnvProxyGateway, "") - kuboRPC := getEnvs(EnvKuboRPC, DefaultKuboRPC) + kuboRPC := getEnvs(EnvKuboRPC, "") blockCacheSize, err := getEnvInt(EnvBlockCacheSize, lib.DefaultCacheBlockStoreSize) if err != nil { @@ -134,7 +134,10 @@ See documentation at: https://github.com/ipfs/bifrost-gateway/#readme`, log.Printf("%s: %d", EnvBlockCacheSize, blockCacheSize) log.Printf("%s: %t", EnvGraphBackend, useGraphBackend) - log.Printf("Legacy RPC at /api/v0 (%s) provided by %s", EnvKuboRPC, strings.Join(kuboRPC, " ")) + if len(kuboRPC) != 0 { + log.Printf("Legacy RPC at /api/v0 (%s) provided by %s", EnvKuboRPC, strings.Join(kuboRPC, " ")) + } + log.Printf("Path gateway listening on http://127.0.0.1:%d", gatewayPort) log.Printf(" Smoke test (JPG): http://127.0.0.1:%d/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi", gatewayPort) log.Printf("Subdomain gateway configured on dweb.link and http://localhost:%d", gatewayPort)