This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add HTTP Gateway support for /ipns/ paths (#2020)
> Part of an effort to run embedded js-ipfs in Brave 🦁 ipfs/ipfs-companion#716 > Fixes #1918 This PR will add support for `/ipns/` paths at HTTP Gateway. Smoke test: [/ipns/tr.wikipedia-on-ipfs.org](http://127.0.0.1:9090/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html) (IPNS+DNSLink+HAMT-sharded website) This PR depends on the following merged PRs: - Gateway Improvements from #1989 (after merging #1989 I will rebase this PR, which will remove first two commits) - PeerID eg. `/ipns/<PeerId-as-multihash-b58>` - requires #2002 to land first - `/ipns/<libp2p-key-in-cidv1>` - requires multiformats/js-multicodec#45 - DNSLink eg. `/ipns/<fqdn>/path/file` like `/ipns/docs.ipfs.io/assets/logo.svg` - requires #2002 to land first - HAMT shard support eg. `/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html` (`wiki` is a sharded directory) - requires ipfs/js-ipfs-http-response#22 and ipfs-inactive/js-ipfs-mfs#48 to land first - Tests for `/ipns/` License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
- Loading branch information
Showing
6 changed files
with
170 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
'use strict' | ||
|
||
const Joi = require('@hapi/joi') | ||
const resources = require('../resources') | ||
|
||
module.exports = { | ||
method: '*', | ||
path: '/ipfs/{cid*}', | ||
options: { | ||
handler: resources.gateway.handler, | ||
pre: [ | ||
{ method: resources.gateway.checkCID, assign: 'args' } | ||
], | ||
response: { | ||
ranges: false // disable built-in support, we do it manually | ||
}, | ||
ext: { | ||
onPostHandler: { method: resources.gateway.afterHandler } | ||
module.exports = [ | ||
{ | ||
method: '*', | ||
path: '/ipfs/{path*}', | ||
options: { | ||
handler: resources.gateway.handler, | ||
validate: { | ||
params: { | ||
path: Joi.string().required() | ||
} | ||
}, | ||
response: { | ||
ranges: false // disable built-in support, handler does it manually | ||
}, | ||
ext: { | ||
onPostHandler: { method: resources.gateway.afterHandler } | ||
} | ||
} | ||
}, | ||
{ | ||
method: '*', | ||
path: '/ipns/{path*}', | ||
options: { | ||
handler: resources.gateway.handler, | ||
validate: { | ||
params: { | ||
path: Joi.string().required() | ||
} | ||
}, | ||
response: { | ||
ranges: false // disable built-in support, handler does it manually | ||
}, | ||
ext: { | ||
onPostHandler: { method: resources.gateway.afterHandler } | ||
} | ||
} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
'use strict' | ||
|
||
module.exports = [require('./gateway')] | ||
module.exports = require('./gateway') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters