Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,13 @@ ProxyServer.prototype.removeHandler = function() {
return this;
};

ProxyServer.prototype.removeHandlers = function() {
this.handlers = [];
};


exports.createServer = function (options) {

return new ProxyServer(options);

};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "intercept-proxy",
"description": "A light weight proxy for exposing a remote site through localhost and replace select resources with local versions for testing and development purposes.",
"version": "0.3.3",
"version": "0.4.0",
"authors": [
"Johan Öbrink <johan.obrink@gmail.com> (https://github.com/johanobrink)"
],
Expand Down
17 changes: 16 additions & 1 deletion tests/registerHandler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ describe('handlers', function() {
expect(server.handlers['/foo']['PUT']).to.equal(handler);
});

it('should remove all handlers', function() {
var handler = function(req, res) {};

server.addHandler('/foo', 'GET', handler);
server.addHandler('/foo2', 'GET', handler);

expect(server.handlers['/foo']['GET']).to.equal(handler);
expect(server.handlers['/foo2']['GET']).to.equal(handler);

server.removeHandlers();

expect(server.handlers['/foo']).to.be.undefined;
expect(server.handlers['/foo2']).to.be.undefined;
});

describe('calls to handlers', function() {
it('should call a handler for matching path', function(done) {

Expand Down Expand Up @@ -132,4 +147,4 @@ describe('handlers', function() {

});

});
});