Created
July 10, 2011 20:46
-
-
Save alessioalex/1074953 to your computer and use it in GitHub Desktop.
This file contains 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 Controller = require(GO.paths.controller); | |
GO.aop = require(GO.paths.vendor + '/aop'); | |
GO.time = require(GO.paths.vendor + '/bm'); | |
var Application = function(app) { | |
app.get('*', function(req, res, next) { | |
var ctrl = new Controller(req, res, next); | |
// GO.Socket.emit('data', 'custom2: ' + GO.utils.uid(10)); | |
var uid = GO.utils.uid(10), | |
time = new Date().toGMTString(); | |
GO.aop.before(ctrl, "_execute", function() { | |
// The Benchmarking Aspect | |
GO.time('render_page ' + uid); | |
}); | |
GO.aop.after(ctrl, "_execute", function() { | |
// The Benchmarking Aspect | |
var msg = "Rendering page '" + req.url + "' took: "; | |
GO.Socket.emit('data', { | |
'time' : time, | |
'type' : 'benchmark', | |
'msg' : GO.time('render_page ' + uid, msg), | |
'uid' : uid | |
}); | |
// The Logging Aspect - Apache style logging | |
GO.Socket.emit('data', { | |
'time' : time, | |
'type' : 'visit logger', | |
'msg' : "GET '" + req.url + "' " + req.headers['user-agent'] | |
}); | |
}); | |
ctrl._execute(req, res, next); | |
}); | |
}; | |
module.exports = Application; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment