File tree 4 files changed +44
-21
lines changed
4 files changed +44
-21
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ const resources = require('../../gateway/resources')
5
5
module . exports = [
6
6
{
7
7
method : '*' ,
8
- path : '/ipfs/{cid *}' ,
8
+ path : '/ipfs/{immutableId *}' ,
9
9
options : {
10
10
pre : [
11
- { method : resources . gateway . checkCID , assign : 'args' }
11
+ { method : resources . gateway . checkImmutableId , assign : 'args' }
12
12
]
13
13
} ,
14
14
handler : resources . gateway . handler
Original file line number Diff line number Diff line change @@ -45,12 +45,17 @@ class ResponseStream extends PassThrough {
45
45
}
46
46
47
47
module . exports = {
48
- checkCID ( request , h ) {
49
- if ( ! request . params . cid ) {
48
+ checkImmutableId ( request , h ) {
49
+ if ( ! request . params . immutableId ) {
50
50
throw Boom . badRequest ( 'Path Resolve error: path must contain at least one component' )
51
51
}
52
-
53
- return { ref : `/ipfs/${ request . params . cid } ` }
52
+ return { ref : `/ipfs/${ request . params . immutableId } ` }
53
+ } ,
54
+ checkMutableId ( request , h ) {
55
+ if ( ! request . params . mutableId ) {
56
+ throw Boom . badRequest ( 'Path Resolve error: path must contain at least one component' )
57
+ }
58
+ return { ref : `/ipns/${ request . params . mutableId } ` }
54
59
} ,
55
60
56
61
async handler ( request , h ) {
Original file line number Diff line number Diff line change 2
2
3
3
const resources = require ( '../resources' )
4
4
5
- module . exports = {
6
- method : '*' ,
7
- path : '/ipfs/{cid*}' ,
8
- options : {
9
- handler : resources . gateway . handler ,
10
- pre : [
11
- { method : resources . gateway . checkCID , assign : 'args' }
12
- ] ,
13
- response : {
14
- ranges : false // disable built-in support, we do it manually
15
- } ,
16
- ext : {
17
- onPostHandler : { method : resources . gateway . afterHandler }
5
+ module . exports = [
6
+ {
7
+ method : '*' ,
8
+ path : '/ipfs/{immutableId*}' ,
9
+ options : {
10
+ handler : resources . gateway . handler ,
11
+ pre : [
12
+ { method : resources . gateway . checkImmutableId , assign : 'args' }
13
+ ] ,
14
+ response : {
15
+ ranges : false // disable built-in support, we do it manually
16
+ } ,
17
+ ext : {
18
+ onPostHandler : { method : resources . gateway . afterHandler }
19
+ }
20
+ }
21
+ } ,
22
+ {
23
+ method : '*' ,
24
+ path : '/ipns/{mutableId*}' ,
25
+ options : {
26
+ handler : resources . gateway . handler ,
27
+ pre : [
28
+ { method : resources . gateway . checkMutableId , assign : 'args' }
29
+ ] ,
30
+ response : {
31
+ ranges : false // disable built-in support, we do it manually
32
+ } ,
33
+ ext : {
34
+ onPostHandler : { method : resources . gateway . afterHandler }
35
+ }
18
36
}
19
37
}
20
- }
38
+ ]
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- module . exports = [ require ( './gateway' ) ]
3
+ module . exports = [ ... require ( './gateway' ) ]
You can’t perform that action at this time.
0 commit comments