Skip to content

Instantly share code, notes, and snippets.

@othiym23
Created October 30, 2013 06:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save othiym23/7227790 to your computer and use it in GitHub Desktop.
Save othiym23/7227790 to your computer and use it in GitHub Desktop.
Attempt at a repro case for newrelic/node-newrelic#73 (needs more detail).
'use strict';
var express = require('express');
var newrelic = require('newrelic');
function allowCrossDomain(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
function time_logger(req, res, next) {
var stamp = new Date();
console.log("DING DONG:", stamp);
res.set('X-Date', stamp);
next();
}
function signer(req, res, next) {
res.set('X-Authed-By', 'othiym23');
next();
}
function authentication(req, res, next) {
next();
}
var errors = {
middleware : function (err, req, res, next) {
console.log('lol:', err.message);
next(err);
}
};
var controllers = {
user : {
show : function (req, res) {
res.send(200, {status : 'ok'});
}
}
};
var app = express();
app.use(allowCrossDomain);
var user_show_middlewares = [
time_logger,
express.bodyParser(),
signer,
authentication,
function (req, res, next) {
newrelic.setControllerName('users', 'show');
next();
},
controllers.user.show
];
app.get('/v1/users/:id', user_show_middlewares);
app.use(errors.middleware);
require('http').createServer(app).listen(8080, function () {
console.log("listening on port 8080");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment