mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Support both GET and POST in the count API
This commit is contained in:
parent
d12e2990be
commit
41fe73e57e
3 changed files with 28 additions and 11 deletions
|
@ -2,16 +2,14 @@ import _ from 'lodash';
|
|||
import handleESError from '../../../../lib/handle_es_error';
|
||||
|
||||
export default function registerCount(server) {
|
||||
server.route({
|
||||
path: '/api/kibana/{id}/_count',
|
||||
method: 'POST',
|
||||
handler: function (req, reply) {
|
||||
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, req);
|
||||
const path = '/api/kibana/{id}/_count';
|
||||
const 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});
|
||||
|
@ -20,6 +18,17 @@ export default function registerCount(server) {
|
|||
reply(handleESError(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
server.route({
|
||||
path,
|
||||
method: 'POST',
|
||||
handler
|
||||
});
|
||||
|
||||
server.route({
|
||||
path,
|
||||
method: 'GET',
|
||||
handler
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,6 +49,14 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
bdd.it('should support GET requests as well', function () {
|
||||
return request.get('/kibana/foo-*/_count')
|
||||
.expect(200)
|
||||
.then(function (response) {
|
||||
expect(response.body.count).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should return 404 if a pattern matches no indices', function () {
|
||||
return request.post('/kibana/doesnotexist-*/_count')
|
||||
.expect(404);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
var bdd = require('intern!bdd');
|
||||
var serverConfig = require('intern/dojo/node!../../../serverConfig');
|
||||
var serverConfig = require('intern/dojo/node!../../../server_config');
|
||||
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
|
||||
var request = require('intern/dojo/node!supertest-as-promised');
|
||||
var url = require('intern/dojo/node!url');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue