connect-mount
This is a standalone middleware for mounting a path. This is a common feature of Express/Connect/etc typically exposed as app.use(string, fn)
.
This also stores req.baseUrl
, req.path
and req.originalUrl
like in Express.
This module was adapted from stacked.
Install
npm install connect-mount --save
Examples
var http = ;var mount = ;var serveStatic = ; // could also be express, connect, etcvar app = ; // when user hits /foo they are actually being served 'build' assetsapp; http;
Usage
middleware = mount(path, fn)
Mounts the path
, like '/foo'
, so that when it's hit, you will get a callback in fn(req, res, next)
. After next()
is called, the URL is reset to its original value for fall-back middleware functions.
For example, if the users requests '/foo/bar/test.txt', the function will be called like so:
var mount = ;var serveStatic = ; var handler = ; http;
License
MIT, see LICENSE.md for details.