Comparing version 1.2.0 to 1.3.0
@@ -6,2 +6,5 @@ // Requires | ||
var httpProxy = require('http-proxy'); | ||
function GroupBalancer(config, resources) { | ||
@@ -84,3 +87,3 @@ // Bind methods to resource | ||
.then(function() { | ||
console.log('backend =', backend); | ||
console.log('Handled: ', backend.host+req.url); | ||
@@ -97,3 +100,7 @@ // Handle (actual proxying) | ||
.fail(function(err) { | ||
req.resume(); | ||
console.log('HTTP ERROR='); | ||
console.log(err.stack); | ||
res.write(err.stack); | ||
@@ -106,2 +113,3 @@ res.write('\nERROR: Loadfire does not know how to handle that request\n'); | ||
GroupBalancer.prototype.handleWs = function(req, socket, head) { | ||
var self = this; | ||
@@ -116,16 +124,27 @@ // Pause request stream | ||
// Build proxy | ||
var proxy = new httpProxy.HttpProxy({ | ||
target: _.clone(backend) | ||
}); | ||
// Apply middleware | ||
return self.applyMiddleware(resource, req, null) | ||
.then(function() { | ||
console.log('handledWs: ', backend.host+req.url); | ||
// Actual proxying | ||
proxy.proxyWebSocketRequest(req, socket, head); | ||
// Build proxy | ||
var proxy = new httpProxy.HttpProxy({ | ||
target: _.clone(backend) | ||
}); | ||
// Resume request | ||
req.resume(); | ||
// Actual proxying | ||
proxy.proxyWebSocketRequest(req, socket, head); | ||
return backend; | ||
// Resume request | ||
req.resume(); | ||
return backend; | ||
}); | ||
}) | ||
.fail(function(err) { | ||
req.resume(); | ||
console.log('WS ERROR ='); | ||
console.log(err.stack); | ||
socket.write('ERROR: Loadfire does not know how to handle that request'); | ||
@@ -132,0 +151,0 @@ socket.close(); |
{ | ||
"name" : "loadfire", | ||
"version" : "1.2.0", | ||
"version" : "1.3.0", | ||
"description" : "A clean and simple load balancer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
18778
435
3