|
1 | 1 | ---
|
2 |
| -title: libp2p Transport Gateway Specification |
| 2 | +title: libp2p+HTTP Transport Gateway Specification |
3 | 3 | description: >
|
4 |
| - The libp2p Transport Gateway specification describes how Gateway APIs can be used over libp2p transports. |
| 4 | + The libp2p Transport Gateway specification describes how HTTP Gateway semantics can be used over libp2p transports. |
5 | 5 | date: 2023-08-29
|
6 | 6 | maturity: reliable
|
7 | 7 | editors:
|
8 | 8 | - name: Adin Schmahmann
|
9 | 9 | github: aschmahmann
|
| 10 | + affiliation: |
| 11 | + name: Protocol Labs |
| 12 | + url: https://protocol.ai/ |
10 | 13 | - name: Marcin Rataj
|
11 | 14 | github: lidel
|
12 | 15 | url: https://lidel.org/
|
| 16 | + affiliation: |
| 17 | + name: Protocol Labs |
| 18 | + url: https://protocol.ai/ |
13 | 19 | xref:
|
14 | 20 | - path-gateway
|
15 | 21 | - trustless-gateway
|
16 |
| -tags: ['httpGateways', 'lowLevelHttpGateways'] |
17 |
| -order: 1 |
| 22 | +tags: ['httpGateways', 'lowLevelHttpGateways', 'exchange', 'transport'] |
| 23 | +order: 3 |
18 | 24 | ---
|
19 | 25 |
|
20 |
| -The libp2p Transport Gateway specification describes how Gateway APIs can be used over [libp2p](https://github.com/libp2p/specs) transports. |
| 26 | +## Introduction |
21 | 27 |
|
22 |
| -libp2p has a [http+libp2p specification](https://github.com/libp2p/specs/pull/508) that describes how to use HTTP semantics over stream transports, as well as how to do discovery of what protocols are available (and where they are mounted), on a given endpoint. In order for a given HTTP protocol like the IPFS Gateway API to work in this environment it requires a protocol identifier. |
| 28 | +This specification describes how HTTP Gateway semantics |
| 29 | +and APIs can be used over [libp2p](https://github.com/libp2p/specs) transports. |
23 | 30 |
|
24 |
| -The protocol identifier for the IPFS Gateway when used over libp2p is `/ipfs/gateway`. This protocol identifier is shared among Gateway specifications (e.g. whether an endpoint only supports :cite[trustless-gateway], supports more of :cite[path-gateway], etc. is not considered here). |
| 31 | +## Specification |
| 32 | + |
| 33 | +The [libp2p+HTTP specification](https://github.com/libp2p/specs/pull/508) |
| 34 | +describes how to use HTTP semantics over stream transports, as well as how |
| 35 | +to do discovery of what protocols are available (and where they are mounted). |
| 36 | + |
| 37 | +### `.well-known/libp2p` |
| 38 | + |
| 39 | +libp2p application sub-protocols exposed behind `/http/1.1` protocol can be |
| 40 | +discovered by the well-known resource (:cite[rfc8615]) at `.well-known/libp2p`. |
| 41 | + |
| 42 | +#### Protocol identifier |
| 43 | + |
| 44 | +In order for a given HTTP Gateway protocol like the :cite[trustless-gateway] to |
| 45 | +work in this environment it requires a protocol identifier to act as a key in |
| 46 | +the `.well-known/libp2p` mapping file. |
| 47 | + |
| 48 | +The `/http/1.1` sub-protocol identifier for the IPFS Gateway when used over libp2p is: |
| 49 | + |
| 50 | +``` |
| 51 | +/ipfs/gateway |
| 52 | +``` |
| 53 | + |
| 54 | +#### Protocol mounting |
| 55 | + |
| 56 | +A reference `.well-known/libp2p` JSON body with mapping that assumes the gateway to be mounted at `/`: |
| 57 | + |
| 58 | +```js |
| 59 | +{ |
| 60 | + "protocols": { |
| 61 | + "/ipfs/gateway": {"path": "/"}, |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +## Gateway type detection |
| 67 | + |
| 68 | +The protocol identifier is shared among Gateway specifications. |
| 69 | + |
| 70 | +HTTP server mounted behind the `/ipfs/gateway` identifier MUST expose |
| 71 | +:cite[trustless-gateway], but is free to also support other gateway types and |
| 72 | +features. |
| 73 | + |
| 74 | +:::note |
| 75 | + |
| 76 | +Signaling Features on HTTP Gateways is wip in [IPIP-425](https://github.com/ipfs/specs/pull/425). |
| 77 | + |
| 78 | +Until the IPIP is finalized, client implementations SHOULD perform feature |
| 79 | +detection on their own, or assume only the most basic [block (application/vnd.ipld.raw)](https://specs.ipfs.tech/http-gateways/trustless-gateway/#block-responses-application-vnd-ipld-raw) |
| 80 | +response type from :cite[trustless-gateway] is available. |
| 81 | + |
| 82 | +::: |
0 commit comments