Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ca06e29

Browse files
committedFeb 28, 2016
Add /api/v0/config/show endpoint
1 parent 7d21f38 commit ca06e29

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
 

‎src/http-api/resources/config.js

+14
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,17 @@ exports.getOrSet = {
110110
}
111111
}
112112
}
113+
114+
exports.show = (request, reply) => {
115+
return ipfs.config.show((err, config) => {
116+
if (err) {
117+
log.error(err)
118+
return reply({
119+
Message: 'Failed to get config value: ' + err,
120+
Code: 0
121+
}).code(500)
122+
}
123+
124+
return reply(config)
125+
})
126+
}

‎src/http-api/routes/config.js

+6
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ api.route({
1111
handler: resources.config.getOrSet.handler
1212
}
1313
})
14+
15+
api.route({
16+
method: '*',
17+
path: '/api/v0/config/show',
18+
handler: resources.config.show
19+
})

‎tests/test-http-api/test-config.js

+19
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ describe('config', () => {
132132
})
133133
})
134134
})
135+
136+
it('/config/show', (done) => {
137+
api.inject({
138+
method: 'POST',
139+
url: '/api/v0/config/show'
140+
}, res => {
141+
expect(res.statusCode).to.equal(200)
142+
expect(res.result).to.deep.equal(updatedConfig())
143+
done()
144+
})
145+
})
135146
})
136147

137148
describe('using js-ipfs-api', () => {
@@ -221,5 +232,13 @@ describe('config', () => {
221232
})
222233
})
223234
})
235+
236+
it('ipfs.config.show', (done) => {
237+
ctl.config.show((err, res) => {
238+
expect(err).not.to.exist
239+
expect(res).to.deep.equal(updatedConfig())
240+
done()
241+
})
242+
})
224243
})
225244
})

0 commit comments

Comments
 (0)
This repository has been archived.