Skip to content

Commit d65550c

Browse files
committed
libp2p-gw: mapping example and small editorials
1 parent 7300351 commit d65550c

File tree

1 file changed

+65
-7
lines changed

1 file changed

+65
-7
lines changed
Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,82 @@
11
---
2-
title: libp2p Transport Gateway Specification
2+
title: libp2p+HTTP Transport Gateway Specification
33
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.
55
date: 2023-08-29
66
maturity: reliable
77
editors:
88
- name: Adin Schmahmann
99
github: aschmahmann
10+
affiliation:
11+
name: Protocol Labs
12+
url: https://protocol.ai/
1013
- name: Marcin Rataj
1114
github: lidel
1215
url: https://lidel.org/
16+
affiliation:
17+
name: Protocol Labs
18+
url: https://protocol.ai/
1319
xref:
1420
- path-gateway
1521
- trustless-gateway
16-
tags: ['httpGateways', 'lowLevelHttpGateways']
17-
order: 1
22+
tags: ['httpGateways', 'lowLevelHttpGateways', 'exchange', 'transport']
23+
order: 3
1824
---
1925

20-
The libp2p Transport Gateway specification describes how Gateway APIs can be used over [libp2p](https://github.com/libp2p/specs) transports.
26+
## Introduction
2127

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.
2330

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

Comments
 (0)