add logging by referer header
This commit is contained in:
parent
01f59d9b02
commit
3b95041613
1 changed files with 17 additions and 4 deletions
21
index.js
21
index.js
|
@ -6,11 +6,24 @@ var log = console.log;
|
|||
|
||||
var app = Express();
|
||||
|
||||
app.use(serveStatic('static'));
|
||||
function logMiddleware(req,res,next){
|
||||
log(req.method.toUpperCase() +' '+ req.url);
|
||||
log( '\t'+ new Date().toISOString() );
|
||||
if(req.headers && req.headers.referer){
|
||||
log('\tReferer: '+req.headers.referer);
|
||||
}
|
||||
return next(null);
|
||||
}
|
||||
|
||||
app.use(logMiddleware);
|
||||
|
||||
app.use(
|
||||
serveStatic('static',{
|
||||
maxAge:'1d'
|
||||
})
|
||||
);
|
||||
|
||||
app.get('/api/feed',function(req,res){
|
||||
// logging
|
||||
log(req.url);
|
||||
|
||||
// get feed url
|
||||
var feedUrl = req.query.url;
|
||||
|
@ -40,5 +53,5 @@ app.get('/api/feed',function(req,res){
|
|||
});
|
||||
|
||||
app.listen(process.env.PORT || 8000,function(){
|
||||
console.log('listening on '+(process.env.PORT || 8000));
|
||||
log('listening on '+(process.env.PORT || 8000));
|
||||
});
|
||||
|
|
Reference in a new issue