Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable customising delegated http router #654

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

2color
Copy link
Member

@2color 2color commented Oct 16, 2024

Description

Allow passing delegated routing client options, e.g. IPIP-484 filters, to the delegated HTTP router.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@2color 2color requested a review from a team as a code owner October 16, 2024 11:33
Comment on lines 97 to 99
export function delegatedHTTPRouting (url: string | URL, init: DelegatedRoutingV1HttpApiClientInit = {}): Routing {
return new DelegatedHTTPRouter(new URL(url), init)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably also need to update the createHelia functions to support passing these through right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the normal helia, i .e. HeliaP2P, we don't even instantitate the delegatedHTTPRouter, so not relevant:

const helia = new HeliaP2P({
...init,
libp2p,
datastore,
blockstore,
blockBrokers: init.blockBrokers ?? [
trustlessGateway(),
bitswap()
],
routers: init.routers ?? [
libp2pRouting(libp2p),
httpGatewayRouting()
],
metrics: libp2p.metrics
})

For @helia/http, we do use the delegatedHTTPRouter: https://github.com/ipfs/helia/blob/f904041bdd2643fabd204485825d4761fc44a83f/packages/http/src/index.ts/#L79-L82

But if you want to cutsomise the delegatedHTTPRouter options, you can just instantiate it yourself and pass it in via init.router (a bit like how we do it in the example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants