@cryptotaxi247 / kubo / commits / dfd244816

feat(gateway): human error pages, dag-cbor/dag-json preview (#9904)

Co-authored-by: Marcin Rataj <lidel@lidel.org>

Henrique Dias committed Jun 1, 2023 at 01:43 UTC dfd244816a7701c61dc2e0fe944cfc92395c5652
6 files changed +25 -10
docs/changelogs/v0.21.md
+17 -2
@@ -8,7 +8,8 @@
8 - [🔦 Highlights](#-highlights)
9 - [Saving previously seen nodes for later bootstrapping](#saving-previously-seen-nodes-for-later-bootstrapping)
10 - [`Gateway.DeserializedResponses` config flag](#gatewaydeserializedresponses-config-flag)
11 - - [`client/rpc` migration of go-ipfs-http-client](#clientrpc-migration-of-go-ipfs-http-client)
11 + - [`client/rpc` migration of `go-ipfs-http-client`](#clientrpc-migration-of-go-ipfs-http-client)
12 + - [Gateway: DAG-CBOR/-JSON previews and improved error pages](#gateway-dag-cbor-json-previews-and-improved-error-pages)
13 - [📝 Changelog](#-changelog)
14 - [👨‍👩‍👧‍👦 Contributors](#-contributors)
15
@@ -59,7 +60,7 @@ third-party CIDs.
60 #### `client/rpc` migration of `go-ipfs-http-client`
61
62 The [`go-ipfs-http-client`](https://github.com/ipfs/go-ipfs-http-client) RPC has
62 -been migrated into [`client/rpc`](./client/rpc).
63 +been migrated into [`kubo/client/rpc`](../../client/rpc).
64
65 With this change the two will be kept in sync, in some previous releases we
66 updated the CoreAPI with new Kubo features but forgot to port thoses to the
@@ -69,6 +70,20 @@ version.
70 For smooth transition `v0.7.0` of `go-ipfs-http-client` provides updated stubs
71 for Kubo `v0.21`.
72
73 +#### Gateway: DAG-CBOR/-JSON previews and improved error pages
74 +
75 +In this release, we improved the HTML templates of our HTTP gateway:
76 +
77 +1. You can now preview the contents of a DAG-CBOR and DAG-JSON document from your browser, as well as follow any IPLD Links ([CBOR Tag 42](https://github.com/ipld/cid-cbor/)) contained within them.
78 +2. The HTML directory listings now contain [updated, higher-definition icons](https://user-images.githubusercontent.com/5447088/241224419-5385793a-d3bb-40aa-8cb0-0382b5bc56a0.png).
79 +3. On gateway error, instead of a plain text error message, web browsers will now get a friendly HTML response with more details regarding the problem.
80 +
81 +HTML responses are returned when request's `Accept` header includes `text/html`.
82 +
83 +| DAG-CBOR Preview | Error Page |
84 +| ---- | ---- |
85 +| ![DAG-CBOR Preview](https://github.com/ipfs/boxo/assets/5447088/973f05d1-5731-4469-9da5-d1d776891899) | ![Error Page](https://github.com/ipfs/boxo/assets/5447088/14c453df-adbc-4634-b038-133121914550) |
86 +
87 ### 📝 Changelog
88
89 ### 👨‍👩‍👧‍👦 Contributors
docs/examples/kubo-as-a-library/go.mod
+1 -1
@@ -7,7 +7,7 @@ go 1.18
7 replace github.com/ipfs/kubo => ./../../..
8
9 require (
10 - github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe
10 + github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076
11 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
12 github.com/libp2p/go-libp2p v0.27.3
13 github.com/multiformats/go-multiaddr v0.9.0
docs/examples/kubo-as-a-library/go.sum
+2 -2
@@ -321,8 +321,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
321 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
322 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
323 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
324 -github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe h1:H6ETX0d5BiNTd1XIK8VARmEn0hpYpYdKKKp3rUJBLjY=
325 -github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
324 +github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076 h1:jkmzkt/eRxC+tAOgUYOoQh50Bvfnun/Dy3n72tRSkmo=
325 +github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
326 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
327 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
328 github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
go.mod
+1 -1
@@ -16,7 +16,7 @@ require (
16 github.com/gogo/protobuf v1.3.2
17 github.com/google/uuid v1.3.0
18 github.com/hashicorp/go-multierror v1.1.1
19 - github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe
19 + github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076
20 github.com/ipfs/go-block-format v0.1.2
21 github.com/ipfs/go-cid v0.4.1
22 github.com/ipfs/go-cidutil v0.1.0
go.sum
+2 -2
@@ -356,8 +356,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
356 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
357 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
358 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
359 -github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe h1:H6ETX0d5BiNTd1XIK8VARmEn0hpYpYdKKKp3rUJBLjY=
360 -github.com/ipfs/boxo v0.8.2-0.20230530175401-c23df3837fbe/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
359 +github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076 h1:jkmzkt/eRxC+tAOgUYOoQh50Bvfnun/Dy3n72tRSkmo=
360 +github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
361 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
362 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
363 github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
test/sharness/t0123-gateway-json-cbor.sh
+2 -2
@@ -349,7 +349,7 @@ test_native_dag () {
349 # As this is generated, we don't return immutable Cache-Control, even on /ipfs (same as for dir-index-html)
350
351 test_expect_success "GET $name on /ipfs with Accept: text/html returns HTML (dag-index-html)" '
352 - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 &&
352 + curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID/" > curl_output 2>&1 &&
353 test_should_not_contain "Content-Disposition" curl_output &&
354 test_should_not_contain "Cache-Control" curl_output &&
355 test_should_contain "Etag: \"DagIndex-" curl_output &&
@@ -358,7 +358,7 @@ test_native_dag () {
358 '
359
360 test_expect_success "GET $name on /ipns with Accept: text/html returns HTML (dag-index-html)" '
361 - curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" > curl_output 2>&1 &&
361 + curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID/" > curl_output 2>&1 &&
362 test_should_not_contain "Content-Disposition" curl_output &&
363 test_should_not_contain "Cache-Control" curl_output &&
364 test_should_contain "Etag: \"DagIndex-" curl_output &&