constlibp2p = awaitcreateLibp2p({ // other config here services: { delegatedRouting:delegatedRoutingV1HttpApiClient({ url:'https://example.org' }) } })
// later this will use the configured HTTP gateway awaitlibp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
Caching
By default, the client caches successful (200) delegated routing responses in browser environments (that support the Cache API) for a duration of 5 minutes. The client does this by adding an x-cache-expires header to the response object.
If caching is enabled, the client will cache responses for the duration of cacheTTL milliseconds.
If cacheTTL is 0, caching is disabled:
The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484.
The filter options be set globally, by passing them to the client constructor, or on a per-request basis.
A client implementation of the IPFS Delegated Routing V1 HTTP API that can be used to interact with any compliant server implementation.
Example
How to use with libp2p
The client can be configured as a libp2p service, this will enable it as both a ContentRouting and a PeerRouting implementation
Example
Caching
By default, the client caches successful (200) delegated routing responses in browser environments (that support the Cache API) for a duration of 5 minutes. The client does this by adding an
x-cache-expiresheader to the response object.If caching is enabled, the client will cache responses for the duration of
cacheTTLmilliseconds. IfcacheTTLis 0, caching is disabled:Example
Filtering with IPIP-484
The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484. The filter options be set globally, by passing them to the client constructor, or on a per-request basis.
See
https://github.com/ipfs/specs/pull/484
Example