mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
parent
6b4c4f5426
commit
3c1d605da7
|
|
@ -26,7 +26,7 @@ function error(err, req, res, next) {
|
|||
res.send('Internal Server Error');
|
||||
}
|
||||
|
||||
app.get('/', function(req, res){
|
||||
app.get('/', function () {
|
||||
// Caught and passed down to the errorHandler middleware
|
||||
throw new Error('something broke!');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function users(req, res, next) {
|
|||
})
|
||||
}
|
||||
|
||||
app.get('/middleware', count, users, function(req, res, next){
|
||||
app.get('/middleware', count, users, function (req, res) {
|
||||
res.render('index', {
|
||||
title: 'Users',
|
||||
count: req.count,
|
||||
|
|
@ -99,7 +99,7 @@ function users2(req, res, next) {
|
|||
})
|
||||
}
|
||||
|
||||
app.get('/middleware-locals', count2, users2, function(req, res, next){
|
||||
app.get('/middleware-locals', count2, users2, function (req, res) {
|
||||
// you can see now how we have much less
|
||||
// to pass to res.render(). If we have
|
||||
// several routes related to users this
|
||||
|
|
|
|||
|
|
@ -72,12 +72,12 @@ var userRepos = {
|
|||
// and simply expose the data
|
||||
|
||||
// example: http://localhost:3000/api/users/?api-key=foo
|
||||
app.get('/api/users', function(req, res, next){
|
||||
app.get('/api/users', function (req, res) {
|
||||
res.send(users);
|
||||
});
|
||||
|
||||
// example: http://localhost:3000/api/repos/?api-key=foo
|
||||
app.get('/api/repos', function(req, res, next){
|
||||
app.get('/api/repos', function (req, res) {
|
||||
res.send(repos);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user