You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a new HTTP endpoint that can be used to request records for the
closest peers to a given key that the routing implementation knows
about.
The use-case for this is browser nodes performing random walks to
find peers that they can make a circuit relay reservation on, without
having to be DHT clients to perform the walk which can be undesirable
given all the connection/processing overhead that entails.
-`peer-id` is a [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
114
+
115
+
#### Query Paramters
116
+
117
+
-`closerThan` is an optional [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md) represented as a CIDv1 encoded with `libp2p-key` codec.
118
+
- Returned peer records must be closer to `peer-id` than `closerThan`.
119
+
- If omitted the routing implementation should use it's own [Peer ID](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md).
120
+
121
+
#### Response Status Codes
122
+
123
+
-`200` (OK): the response body contains peer records.
124
+
-`404` (Not Found): must be returned if no matching records are found.
125
+
-`422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
126
+
127
+
#### Response Headers
128
+
129
+
-`Content-Type`: the content type of this response, which MUST be `application/json` or `application/x-ndjson` (see [streaming](#streaming)).
130
+
-`Last-Modified`: an HTTP-date timestamp ([RFC9110, Section 5.6.7](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.7)) of the resolution, allowing HTTP proxies and CDNs to support inexpensive update checks via `If-Modified-Since`
131
+
-`Cache-Control: public, max-age={ttl}, public, stale-while-revalidate={max-ttl}, stale-if-error={max-ttl}`: meaningful cache TTL returned with the response.
132
+
- When present, `ttl` SHOULD be shorter for responses whose resolution ended in no results (e.g. 15 seconds),
133
+
and longer for responses that have results (e.g. 5 minutes).
134
+
- Implementations SHOULD include `max-ttl`, set to the maximum cache window of the underlying routing system.
135
+
For example, if Amino DHT results are returned, `stale-while-revalidate` SHOULD be set to `172800` (48h, which at the time of writing this specification, is the provider record expiration window).
136
+
-`Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
0 commit comments