mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
adding convenient method for client-side routing
This commit is contained in:
parent
0e72c85e0f
commit
cb07546d0b
19
node_modules/frontdoor/lib/section.js
generated
vendored
19
node_modules/frontdoor/lib/section.js
generated
vendored
@ -118,6 +118,25 @@ module.exports = function Section(name, description, types) {
|
||||
sections[name].push(section);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sortcut for client-side routing without a `next`
|
||||
*
|
||||
* Allows you to omit the third argument, "next" and avoid special
|
||||
* treatment in router.js (see "wrapHandler").
|
||||
*
|
||||
* Has a variable number of argumnets: no need to wrap handlers in an array
|
||||
*/
|
||||
this.on = function( path, handler ){
|
||||
var middlewares = Array.prototype.slice.call( arguments, 1 );
|
||||
handler = middlewares.shift();
|
||||
|
||||
middlewares.unshift(function(req, res, next){
|
||||
handler( req, res, next );
|
||||
});
|
||||
|
||||
this._route( path, { method: "get" }, middlewares );
|
||||
};
|
||||
|
||||
this._rootHandler = function(req, res) {
|
||||
this.handle(req, res, function(err) {
|
||||
if (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user