Skip to content

Commit

Permalink
adds mount function. pipeline will be deprecated soon[C
Browse files Browse the repository at this point in the history
  • Loading branch information
sintaxi committed Sep 14, 2013
1 parent 824cc88 commit 807e0b5
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,50 @@ exports.multihost = function(dirPath, options, callback){
).listen(options.port || 9966, callback)
}

/**
* Mount
*
* Offer the asset pipeline as connect middleware
*
*/

exports.mount = function(mountPoint, root){

if(!root){
root = mountPoint
mountPoint = null
}else{
var rx = new RegExp("^" + mountPoint)
}

var finder = middleware.regProjectFinder(root)

return function(req, rsp, next){

if(rx){
if(!req.url.match(rx)) return next()
var originalUrl = req.url
req.url = req.url.replace(rx, "/")
}

finder(req, rsp, function(){
middleware.setup(req, rsp, function(){
middleware.static(req, rsp, function(){
middleware.poly(req, rsp, function(){
middleware.process(req, rsp, function(){
middleware.process(req, rsp, function(){
if(originalUrl) req.url = originalUrl
next()
})
})
})
})
})
})
}
}


/**
* Pipeline
*
Expand Down

0 comments on commit 807e0b5

Please sign in to comment.