Skip to content

Instantly share code, notes, and snippets.

@alessioalex
Created July 10, 2011 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessioalex/1074953 to your computer and use it in GitHub Desktop.
Save alessioalex/1074953 to your computer and use it in GitHub Desktop.
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