http://expressjs.com/guide/routing.html
var express = require('express');
var app = express();
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
res.send('hello world');
});
// POST method route
app.post('/', function (req, res) {
res.send('POST request to the homepage');
});
There is a special routing method, app.all(), which is not derived from any HTTP method. It is used for loading middleware at a path for all request methods.
app.all('/secret', function (req, res, next) {
console.log('Accessing the secret section ...');
next(); // pass control to the next handler
});
A route can be handled using an array of callback functions:
app.get('/example/c', [cb0, cb1, cb2]);
var express = require('express');
var app = express();
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
res.send('hello world');
});
// POST method route
app.post('/', function (req, res) {
res.send('POST request to the homepage');
});
There is a special routing method, app.all(), which is not derived from any HTTP method. It is used for loading middleware at a path for all request methods.
app.all('/secret', function (req, res, next) {
console.log('Accessing the secret section ...');
next(); // pass control to the next handler
});
A route can be handled using an array of callback functions:
app.get('/example/c', [cb0, cb1, cb2]);