Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
refactor!: remove DefaultKuboRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored and lidel committed Aug 14, 2023
1 parent 9d1d9e3 commit 5513547
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions blockstore_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (

const (
EnvProxyGateway = "PROXY_GATEWAY_URL"

DefaultKuboRPC = "http://127.0.0.1:5001"
)

type proxyBlockStore struct {
Expand Down
3 changes: 1 addition & 2 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
11 changes: 7 additions & 4 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 172 in handlers.go

View check run for this annotation

Codecov / codecov/patch

handlers.go#L166-L172

Added lines #L166 - L172 were not covered by tests

// Construct the HTTP handler for the gateway.
handler := withConnect(mux)
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")

Check warning on line 61 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L61

Added line #L61 was not covered by tests

blockCacheSize, err := getEnvInt(EnvBlockCacheSize, lib.DefaultCacheBlockStoreSize)
if err != nil {
Expand Down Expand Up @@ -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, " "))
}

Check warning on line 139 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L137-L139

Added lines #L137 - L139 were not covered by tests

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)
Expand Down

0 comments on commit 5513547

Please sign in to comment.