Skip to content

Commit

Permalink
Hapi can accept two methods for one route
Browse files Browse the repository at this point in the history
  • Loading branch information
Bargs committed Mar 15, 2016
1 parent 41fe73e commit 6b16b0b
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/plugins/kibana/server/routes/api/search/count/register_count.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import _ from 'lodash';
import handleESError from '../../../../lib/handle_es_error';

export default function registerCount(server) {
const path = '/api/kibana/{id}/_count';
const handler = function (req, reply) {
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, req);
server.route({
path: '/api/kibana/{id}/_count',
method: ['POST', 'GET'],
handler: function (req, reply) {
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, req);

boundCallWithRequest('count', {
allowNoIndices: false,
index: req.params.id
})
boundCallWithRequest('count', {
allowNoIndices: false,
index: req.params.id
})
.then(
function (res) {
reply({count: res.count});
Expand All @@ -18,17 +20,6 @@ export default function registerCount(server) {
reply(handleESError(error));
}
);
};

server.route({
path,
method: 'POST',
handler
});

server.route({
path,
method: 'GET',
handler
}
});
}

0 comments on commit 6b16b0b

Please sign in to comment.