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

Commit

Permalink
Merge pull request #74 from ipfs/feature/http-api-config-show
Browse files Browse the repository at this point in the history
Add /api/v0/config/show endpoint
  • Loading branch information
daviddias committed Feb 28, 2016
2 parents 7d21f38 + ca06e29 commit 876ab2e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/http-api/resources/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
6 changes: 6 additions & 0 deletions src/http-api/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ api.route({
handler: resources.config.getOrSet.handler
}
})

api.route({
method: '*',
path: '/api/v0/config/show',
handler: resources.config.show
})
19 changes: 19 additions & 0 deletions tests/test-http-api/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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()
})
})
})
})

0 comments on commit 876ab2e

Please sign in to comment.