( generated on the "<%= source %>" )

Basic and advanced routing

Here are many different routes defined which you can all test out and see the results.

Example 1

server.get('/user/:id', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /user/:id - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 2

server.get('/users/:id?', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /users/:id? - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 3

server.get('/files/*', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /files/* - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 4

server.get('/files/*.*', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /files/*.* - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 5

server.get('/person/:id/:operation?', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /person/:id/:operation? - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 6

server.get('/product.:format', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /product.:format - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 7

server.get('/products.:format?', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /products.:format? - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 8

server.get('/persons/:id.:format?', function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /persons/:id.:format? - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 9

server.get(/\/regex\/([^\/]+)\/?/, function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /\/regex\/([^\/]+)\/?/ - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.

Example 10

server.get(/^\/regexp?(?:\/(\d+)(?:\.\.(\d+))?)?/, function(request, response) {
  response.render('routing/output', {
    title: 'Client Express JS - /^\/regexp?(?:\/(\d+)(?:\.\.(\d+))?)?/ - Basic and advanced routing', 
    source: 'client', 
    processedRequest: processRequestObject(request) // used to display the request values
  });
});
Click on the links below to test the different routes.