diff --git a/source/maintenance.js b/source/maintenance.js index a299b11..a7f43d5 100644 --- a/source/maintenance.js +++ b/source/maintenance.js @@ -56,6 +56,7 @@ function maintenance(app, options) { }; var handle = function (req, res) { + var isApi = api && req.url.indexOf(api) === 0; res.status(status); @@ -69,10 +70,21 @@ function maintenance(app, options) { var middleware = function (req, res, next) { if (mode) { - return handle(req, res); + var request_url = req.url.split("?")[0]; + if(request_url === url && ["DELETE","POST"].indexOf(req.method) != -1){ + next(); + } + else{ + return handle(req, res); + } + + + } + else{ + next(); } - next(); + }; var inject = function (app) { diff --git a/test/spec/maintenence.spec.js b/test/spec/maintenence.spec.js index 2dc1e2d..5cbf962 100644 --- a/test/spec/maintenence.spec.js +++ b/test/spec/maintenence.spec.js @@ -85,13 +85,15 @@ describe('maintenance.js', function () { results = body; done(err); }); - - it('should return normal page', function () { - expect(response.statusCode).to.equal(200); - expect(results).to.equal('OK'); - }); + + }); + + it('should return normal page', function () { + expect(response.statusCode).to.equal(200); + expect(results).to.equal('OK'); }); + }); @@ -125,11 +127,13 @@ describe('maintenance.js', function () { done(err); }); - it('should return normal page', function () { - expect(response.statusCode).to.equal(200); - expect(results).to.equal('OK'); - }); }); + + it('should return normal page', function () { + expect(response.statusCode).to.equal(200); + expect(results).to.equal('OK'); + }); + }); @@ -177,10 +181,12 @@ describe('maintenance.js', function () { done(err); }); - it('should return normal page', function () { - expect(response.statusCode).to.equal(200); - expect(results).to.equal('OK'); - }); + + }); + + it('should return normal page', function () { + expect(response.statusCode).to.equal(200); + expect(results).to.equal('OK'); }); @@ -249,7 +255,9 @@ describe('maintenance.js', function () { describe('and return back to normal', function () { beforeEach(function (done) { - request.del(url + '/maintenance?access_key=secret', done); + request.del(url + '/maintenance?access_key=secret', function(err,resp,body){ + done(err,body); + }); }); beforeEach(function (done) { @@ -259,13 +267,13 @@ describe('maintenance.js', function () { done(err); }); - it('should return normal page', function () { - expect(response.statusCode).to.equal(200); - expect(results).to.equal('OK'); - }); }); - + it('should return normal page', function () { + expect(response.statusCode).to.equal(200); + expect(results).to.equal('OK'); + }); + }); }); });