Restify support for Node.js


Introduction

The Node.js extension supports routing using the Restify module.

Objects

This extension, when Restify module is found in the source code, may create the following objects:

Icon Description
Restify GET Operation
Restify POST Operation
Restify PUT Operation
Restify DELETE Operation
Restify PATCH Operation

Example

The following is an example of application using restify to handle URIs:

var restify = require('restify');

function send(req, res, next) {
  res.send('hello ' + req.params.name);
  next();
}

var server = restify.createServer();

server.post('/hello', function create(req, res, next) {
  res.send(201, Math.random().toString(36).substr(3, 8));
  return next();
});

server.put('/hello', send);

server.get('/hello/:name', function create(req, res, next) {
  res.send(201, Math.random().toString(36).substr(3, 8));
  return next();
},send);

server.head('/hello/:name', send);

server.patch('/hello/:name', function patch(req, res, next) {
  res.send(200, req.body);
  return next();
});

server.del('hello/:name', function rm(req, res, next) {
  res.send(204);
  return next();
});

server.listen(8080, function() {
  console.log('%s listening at %s', server.name, server.url);
});

The code above will create the links and objects below: