Created
October 6, 2015 13:38
-
-
Save chnbohwr/1c7388c4a9da41a9f481 to your computer and use it in GitHub Desktop.
express middleware
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 express = require('express'); | |
var app = express(); | |
function showMessage(req,res){ | |
console.log("server has send message"); | |
res.send('Hello World!'); | |
} | |
function checkSession(req,res,next){ | |
//check session number | |
console.log('server have check session'); | |
next(); | |
} | |
app.get('/',checkSession,showMessage); | |
var server = app.listen(3000, function () { | |
var host = server.address().address; | |
var port = server.address().port; | |
console.log('Example app listening at http://%s:%s', host, port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment