diff --git a/lib/buildroutes.js b/lib/buildroutes.js index 87b3ea9..c06340a 100644 --- a/lib/buildroutes.js +++ b/lib/buildroutes.js @@ -160,28 +160,26 @@ function buildSecurity(options, securityDefinitions, routeSecurity) { */ function resolve(basedir, pathname, method) { var handler; + //If the pathname is already a resolved function, return it. + //In the case of x-handler and x-authorize, users can define + //external handler/authorize modules and functions OR override + //existing x-authorize functions. + if (thing.isFunction(pathname)) { + return pathname; + } try { - //If the pathname is already a resolved function, return it. - //In the case of x-handler and x-authorize, users can define - //external handler/authorize modules and functions OR override - //existing x-authorize functions. - if (thing.isFunction(pathname)) { - return pathname; - } - pathname = path.resolve(basedir, pathname); - handler = require(pathname); - - if (thing.isFunction(handler)) { - return handler; - } - - return method && handler[method]; - } - catch (error) { + } catch (error) { utils.debuglog('Could not find %s.', pathname); return; } + handler = require(pathname); + + if (thing.isFunction(handler)) { + return handler; + } + + return method && handler[method]; } module.exports = buildroutes;