Browse Source

added unroute method

master
mortie 6 years ago
parent
commit
450a0966fb
2 changed files with 21 additions and 2 deletions
  1. 20
    1
      index.js
  2. 1
    1
      package.json

+ 20
- 1
index.js View File

* Args: * Args:
* method: "GET", "POST", "PUT", "DELETE", "ALL" * method: "GET", "POST", "PUT", "DELETE", "ALL"
* path: path, * path: path,
* middleware: middleware array (optional)
* func: function(request, response) * func: function(request, response)
*/ */
route(method, path, middleware, func) { route(method, path, middleware, func) {
throw new Error("Invalid method."); throw new Error("Invalid method.");
} }


// Before is optional
// Middleware is optional
if (func === undefined) { if (func === undefined) {
func = middleware; func = middleware;
middleware = undefined; middleware = undefined;
} }
} }


/*
* Remove a route.
* Args:
* path: path
*/
unroute(path) {
if (path[0] === "^") {
path = "/"+path+"/";
for (var i in this._routes) {
var str = this._routes[i].pattern.toString();
if (path === str)
delete this._routes[i];
}
} else {
delete this._routeMap[path];
}
}

/* /*
* Add a transform. * Add a transform.
* Args: * Args:

+ 1
- 1
package.json View File

{ {
"name": "webframe", "name": "webframe",
"version": "0.4.2",
"version": "0.5.0",
"description": "Web framework.", "description": "Web framework.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

Loading…
Cancel
Save