Created
March 24, 2014 17:10
-
-
Save pherris/9744642 to your computer and use it in GitHub Desktop.
Node app for testing rule forward...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
var retryCount = req.query.retryCount; | |
console.log("req.query.retryCount: " + retryCount); | |
if (!retryCount || retryCount <3) { | |
res.send(500, 'retryCount under 3'); | |
} else { | |
res.send('Hello World' + retryCount); | |
} | |
}); | |
var server = app.listen(3000, function() { | |
console.log('Listening on port %d', server.address().port); | |
}); |
chiappone
commented
Mar 24, 2014
var express = require('express');
var app = express();
app.use (function(req, res, next) {
var data='';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
req.body = data;
next();
});
});
app.post('/', function(req, res){
var retryCount = req.query.retryCount;
console.log("req.query.retryCount: " + retryCount);
console.log(req.body);
if (!retryCount || retryCount <3) {
console.log('500 returned');
res.send(500, 'retryCount under 3');
} else {
console.log('200 returned');
res.send('Hello World' + retryCount);
}
});
var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment