Skip to content

Commit 58bf3c1

Browse files
committed
ping endpoint
1 parent 37b2b20 commit 58bf3c1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/docker.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ Docker.prototype.version = function(callback) {
197197
});
198198
};
199199

200+
Docker.prototype.ping = function(callback) {
201+
if (!callback && typeof(opts) === 'function') {
202+
callback = opts;
203+
opts = null;
204+
}
205+
206+
var optsf = {
207+
path: '/_ping',
208+
method: 'GET',
209+
statusCodes: {
210+
200: true,
211+
500: "server error"
212+
}
213+
};
214+
215+
this.modem.dial(optsf, function(err, data) {
216+
callback(err, data);
217+
});
218+
};
219+
200220
Docker.prototype.getEvents = function(opts, callback) {
201221
if (!callback && typeof(opts) === 'function') {
202222
callback = opts;

test/docker.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ describe("#docker", function() {
6868
});
6969
});
7070

71+
describe("#getPing", function() {
72+
it("should ping server", function(done) {
73+
this.timeout(30000);
74+
75+
function handler(err, data) {
76+
expect(err).to.be.null;
77+
done();
78+
}
79+
80+
docker.ping(handler);
81+
});
82+
});
83+
7184
describe('#pull', function() {
7285
this.timeout(120000);
7386

0 commit comments

Comments
 (0)