var util = require('util');
var journey = require('journey');


/*
 * Create request router and routing table
 */
var router = new(journey.Router);

router.map(function () {

	// Provide a link to the documentation
    this.get('/').bind(function (req, res) {
        res.send(200, {}, { documentation: "somewhere.com" });
    });
    
    
    // Get all bookmarks
	this.get('/bookmarks').bind(function (req, res, params) {
        res.send(501, {}, { placeholder: "Get all bookmarks", fields: params.fields });
    });
    
    // Create new bookmark
    this.post('/bookmarks').bind(function (req, res, data) {
        res.send(501, {}, { placeholder: "Create new bookmark", input: data });
    });
    
    // Get specified bookmark
    this.get(/^bookmarks\/(\d+)$/).bind(function (req, res, id) {
        res.send(501, {}, { placeholder: 'Get bookmark '+id });
    });
    
    // Update specified bookmark
    this.put(/^bookmarks\/(\d+)$/).bind(function (req, res, id, data) {
        res.send(501, {}, { placeholder: 'Update bookmark '+id, input: data });
    });
    
    // Delete specified bookmark
    this.del(/^bookmarks\/(\d+)$/).bind(function (req, res, id) {
        res.send(501, {}, { placeholder: 'Delete bookmark '+id });
    });
        
    
});


/*
 * Create HTTP server
 */
require('http').createServer(function (request, response) {

    var body = "";

	// Collect message body
    request.addListener('data', function (chunk) { body += chunk });

	// Hand off to router
    request.addListener('end', function () {
        router.handle(request, body, function (result) {
            response.writeHead(result.status, result.headers);
            response.end(result.body);
        });
    });
    
}).listen(8080);


util.puts('tasty listening at http://127.0.0.1:8080');

@@ -55,16 +55,45 @@
 rney');%0A
+var tasty = require('tasty');
 %0A%0A/*%0A * 
@@ -201,1094 +201,355 @@
  %7B%0A%0A
-%09// Provide a link to the documentation%0A    this.get('/').bind(function (req, res) %7B%0A        res.send(200, %7B%7D, %7B documentation: %22somewhere.com%22 %7D);%0A    %7D);%0A    %0A    %0A    // Get all bookmarks%0A%09this.get('/bookmarks').bind(function (req, res, params) %7B%0A        res.send(501, %7B%7D, %7B placeholder: %22Get all bookmarks%22, fields: params.fields %7D);%0A    %7D);%0A    %0A    // Create new bookmark%0A    this.post('/bookmarks').bind(function (req, res, data) %7B%0A        res.send(501, %7B%7D, %7B placeholder: %22Create new bookmark%22, input: data %7D);%0A    %7D);%0A    %0A    // Get specified bookmark%0A    this.get(/%5Ebookmarks%5C/(%5Cd+)$/).bind(function (req, res, id) %7B%0A        res.send(501, %7B%7D, %7B placeholder: 'Get bookmark '+id %7D);%0A    %7D);%0A    %0A    // Update specified bookmark%0A    this.put(/%5Ebookmarks%5C/(%5Cd+)$/).bind(function (req, res, id, data) %7B%0A        res.send(501, %7B%7D, %7B placeholder: 'U
+    this.get('/').bind(tasty.getDocUrl);%0A    %0A%09this.get('/bookmarks').bind(tasty.getAllBookmarks);%0A%09%0A    this.post('/bookmarks').bind(tasty.createBookmark);%0A    this.get(/%5Ebookmarks%5C/(%5Cd+)$/).bind(tasty.getBookmark);%0A    this.put(/%5Ebookmarks%5C/(%5Cd+)$/).bind(tasty.u
 pdate
- b
+B
 ookmark
- '+id, input: data %7D);%0A    %7D);%0A    %0A    // Delete specified bookmark%0A    this.del(/%5Ebookmarks%5C/(%5Cd+)$/).bind(function (req, res, id) %7B%0A        res.send(501, %7B%7D, %7B placeholder: 'D
+);%0A    this.del(/%5Ebookmarks%5C/(%5Cd+)$/).bind(tasty.d
 elete
- b
+B
 ookmark
- '+id %7D);%0A    %7D);%0A        %0A
+);%0A    
     

Modify controller to call 'tasty' module methods