|
|
@@ -136,6 +136,7 @@ class App { |
|
|
|
* Args: |
|
|
|
* method: "GET", "POST", "PUT", "DELETE", "ALL" |
|
|
|
* path: path, |
|
|
|
* middleware: middleware array (optional) |
|
|
|
* func: function(request, response) |
|
|
|
*/ |
|
|
|
route(method, path, middleware, func) { |
|
|
@@ -144,7 +145,7 @@ class App { |
|
|
|
throw new Error("Invalid method."); |
|
|
|
} |
|
|
|
|
|
|
|
// Before is optional |
|
|
|
// Middleware is optional |
|
|
|
if (func === undefined) { |
|
|
|
func = middleware; |
|
|
|
middleware = undefined; |
|
|
@@ -186,6 +187,24 @@ class App { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 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. |
|
|
|
* Args: |