Support ajax posting

This commit is contained in:
Zalmoxisus 2016-01-24 11:05:12 +02:00
parent 943a1c0120
commit db0dd042cc

View File

@ -11,6 +11,11 @@ module.exports.run = function(worker) {
'<p>It works! Now point your app and monitor app to connect to this server.</p>' + '<p>It works! Now point your app and monitor app to connect to this server.</p>' +
'</body></html>'); '</body></html>');
}); });
app.post('/', function(req, res) {
if (!req.body.data) return res.status(404).end();
scServer.exchange.publish('log', req.body.data);
res.send('OK');
});
scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (socket, channel, data, next) { scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (socket, channel, data, next) {
if (channel.substr(0, 3) === 'sc-' || channel === 'respond' || channel === 'log') { if (channel.substr(0, 3) === 'sc-' || channel === 'respond' || channel === 'log') {