|
| 1 | +--- |
| 2 | +title: libp2p+HTTP Transport Gateway Specification |
| 3 | +description: > |
| 4 | + The libp2p Transport Gateway specification describes how HTTP Gateway semantics can be used over libp2p transports. |
| 5 | +date: 2023-10-04 |
| 6 | +maturity: draft |
| 7 | +editors: |
| 8 | + - name: Adin Schmahmann |
| 9 | + github: aschmahmann |
| 10 | + affiliation: |
| 11 | + name: Protocol Labs |
| 12 | + url: https://protocol.ai/ |
| 13 | + - name: Marcin Rataj |
| 14 | + github: lidel |
| 15 | + url: https://lidel.org/ |
| 16 | + affiliation: |
| 17 | + name: Protocol Labs |
| 18 | + url: https://protocol.ai/ |
| 19 | +xref: |
| 20 | + - path-gateway |
| 21 | + - trustless-gateway |
| 22 | +tags: ['httpGateways', 'lowLevelHttpGateways', 'exchange', 'transport'] |
| 23 | +order: 3 |
| 24 | +--- |
| 25 | + |
| 26 | +## Introduction |
| 27 | + |
| 28 | +This specification describes how HTTP Gateway semantics |
| 29 | +and APIs can be used over [libp2p](https://github.com/libp2p/specs) transports. |
| 30 | + |
| 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