/*jshint node:true */

"use strict";

var util = require("util");

var utils = {
	addHref: function(req, doc, prefix, id) {
		doc._href = util.format("%s://%s/rest/%s/%s",
			req.protocol,
			req.headers.host,
			prefix,
			id
		);
	},

	ResponseBody: function(body, mimetype) {
		if (typeof this === "undefined") {
			return new utils.ResponseBody(body, mimetype);
		}

		this.body = body;
		this.mimetype = mimetype;
	},

	ResponseFile: function(path, mimetype) {
		if (typeof this === "undefined") {
			return new utils.ResponseFile(path, mimetype);
		}

		this.path = path;
		this.mimetype = mimetype;
	}
};


module.exports = utils;
@@ -60,16 +60,145 @@
 til%22);%0A%0A
+function extractRoute(req) %7B%0A%09var url = req.url,%0A%09%09orig = req.originalUrl;%0A%0A%09return orig.substring(0, orig.lastIndexOf(url));%0A%7D%0A%0A
 var util
@@ -284,13 +284,10 @@
 //%25s
-/rest
+%25s
 /%25s/
@@ -329,16 +329,38 @@
 s.host,%0A
+%09%09%09extractRoute(req),%0A
 %09%09%09prefi

Determine route prefix automatically