diff --git a/src/http-api/resources/config.js b/src/http-api/resources/config.js index 5f355ef425..e3e0691f2d 100644 --- a/src/http-api/resources/config.js +++ b/src/http-api/resources/config.js @@ -110,3 +110,17 @@ exports.getOrSet = { } } } + +exports.show = (request, reply) => { + return ipfs.config.show((err, config) => { + if (err) { + log.error(err) + return reply({ + Message: 'Failed to get config value: ' + err, + Code: 0 + }).code(500) + } + + return reply(config) + }) +} diff --git a/src/http-api/routes/config.js b/src/http-api/routes/config.js index 10e0bfd70e..cd2314a0ae 100644 --- a/src/http-api/routes/config.js +++ b/src/http-api/routes/config.js @@ -11,3 +11,9 @@ api.route({ handler: resources.config.getOrSet.handler } }) + +api.route({ + method: '*', + path: '/api/v0/config/show', + handler: resources.config.show +}) diff --git a/tests/test-http-api/test-config.js b/tests/test-http-api/test-config.js index 3d6a1b1a63..4e1f0ee25c 100644 --- a/tests/test-http-api/test-config.js +++ b/tests/test-http-api/test-config.js @@ -132,6 +132,17 @@ describe('config', () => { }) }) }) + + it('/config/show', (done) => { + api.inject({ + method: 'POST', + url: '/api/v0/config/show' + }, res => { + expect(res.statusCode).to.equal(200) + expect(res.result).to.deep.equal(updatedConfig()) + done() + }) + }) }) describe('using js-ipfs-api', () => { @@ -221,5 +232,13 @@ describe('config', () => { }) }) }) + + it('ipfs.config.show', (done) => { + ctl.config.show((err, res) => { + expect(err).not.to.exist + expect(res).to.deep.equal(updatedConfig()) + done() + }) + }) }) })