Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(handler): Add options.handler to handle incoming request
A function to use as main request handler (`function(req, res)`). This provides the ability to serve the local directory. Ex: var finalhandler = require('finalhandler'); var serveIndex = require('serve-index'); var serveStatic = require('serve-static'); tinylr({ handler: function(req, res) { var done = finalhandler(req, res); var index = serveIndex(path.resolve('./'), {icons: true}); var serve = serveStatic(path.resolve('./')); if (/changed/.test(req.url)) return this.handle(req, res); serve(req, res, function(err) { if (err) return done(err); index(req, res, done); }); } }); When not defined, the default handler takes place.
- Loading branch information