Skip to content

Commit

Permalink
petea - fixed bug with relative/absolute path for handlers from config
Browse files Browse the repository at this point in the history
  • Loading branch information
smart--petea committed Sep 20, 2014
1 parent 781ade2 commit a5a0c2c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/vatican.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var http = require("http"),
handlerParser = require("./handlerParser"),
processingChain = require("./processingChain"),
mongoose = require("mongoose"),
_ = require("lodash");
_ = require("lodash"),
path = require("path");


module.exports = Vatican;
Expand Down Expand Up @@ -50,7 +51,7 @@ Vatican.prototype.postprocess = function(fn, endpointNames) {
}

Vatican.prototype.parseHandlers = function(cb) {
var dir = this.options.handlers;
var dir = path.isAbsolute(this.options.handlers) ? this.options.handlers : process.cwd() + "/" + this.options.handlers;
var self = this;
handlerParser.parse(dir, function(err, path) {
if(typeof cb == 'function' && err) return cb(err)
Expand Down Expand Up @@ -146,7 +147,7 @@ Vatican.prototype.requestHandler = function (req, res) {
} else {
try {
var request = this.createRequest(req);
var hdlr = this.loadHandler(process.cwd() + "/" + methodFound.handlerPath);
var hdlr = this.loadHandler(methodFound.handlerPath);
res = vaticanResp.improveResponse(res, request, this.options, this.postprocessors);
//Parse the request to grab the parameters
this.parseRequest(request, methodFound.url, req, function(newRequest) {
Expand Down

1 comment on commit a5a0c2c

@smart--petea
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close deleteman#23

Please sign in to comment.