1
0
Fork 0

fixed pathHandler and logging

This commit is contained in:
Frank Celler 2013-07-27 00:03:16 +02:00
parent a20db01143
commit dc247ed1f8
4 changed files with 25 additions and 14 deletions

View File

@ -93,6 +93,7 @@ function routing (req, res) {
}
var func = action.route.callback.controller;
if (func === null || typeof func !== 'function') {
func = actions.errorFunction(action.route,
'Invalid callback definition found for route '

View File

@ -1841,12 +1841,7 @@ function pathHandler (req, res, options, next) {
if (options.hasOwnProperty('root')) {
var root = options.root;
if (root.substr(0, 4) === "app:") {
filename = fs.join(module.appPath(), filename);
}
else if (root.substr(0, 4) === "dev:") {
filename = fs.join(module.devAppPath(), filename);
}
filename = fs.join(root, filename);
}
if (fs.exists(filename)) {

View File

@ -211,7 +211,7 @@ function installAssets (app, routes) {
action: {
"do": "org/arangodb/actions/pathHandler",
"options": {
root: app._id,
root: app._root,
path: fs.join(app._path, directory)
}
}
@ -397,7 +397,7 @@ function mountAalApp (app, mount, options) {
/// @brief computes the routes of an app
////////////////////////////////////////////////////////////////////////////////
function routingAalApp (app, mount, options, dev) {
function routingAalApp (app, mount, options) {
'use strict';
try {
@ -902,7 +902,7 @@ exports.appRoutes = function () {
throw new Error("Cannot find application '" + appId + "'");
}
var r = routingAalApp(app, mount, options, false);
var r = routingAalApp(app, mount, options);
if (r === null) {
throw new Error("Cannot compute the routing table for foxx application '"
@ -953,7 +953,9 @@ exports.developmentRoutes = function () {
throw new Error("Cannot find application '" + appId + "'");
}
var r = routingAalApp(app, mount, options, true);
setupApp(app, mount, options.prefix);
var r = routingAalApp(app, mount, options);
if (r === null) {
throw new Error("Cannot compute the routing table for foxx application '"

View File

@ -871,10 +871,23 @@ BaseMiddleware = function (templateCollection, helperCollection) {
response = _.extend(response, responseFunctions);
next();
if (trace) {
console.log("%s, outgoing response of type %s, body length: %d",
options.app.mount,
response.contentType,
parseInt(response.body.length, 10));
if (response.hasOwnProperty("body")) {
console.log("%s, outgoing response of type %s, body length: %d",
options.app.mount,
response.contentType,
parseInt(response.body.length, 10));
}
else if (response.hasOwnProperty("bodyFromFile")) {
console.log("%s, outgoing response of type %s, body file: %s",
options.app.mount,
response.contentType,
response.bodyFromFile);
}
else {
console.log("%s, outgoing response of type %s, no body",
options.app.mount,
response.contentType);
}
}
};