Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding `logger` method and separating the middleware for specific pat…

…hs from all
  • Loading branch information...
commit 816dffb7a97cacfa2c6f7d2f2068dfdde11b39c4 1 parent 3eec506
@mvrilo authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/frank.js
View
11 lib/frank.js
@@ -20,6 +20,7 @@ module.exports = frank;
this.path = path;
this.route = route = [method.toUpperCase(), path].join(' ');
+ this.middleware = [];
handler[route] = {};
handler[route].method = method.toUpperCase();
@@ -38,6 +39,10 @@ frank.fn.then = function(callback) {
return this;
}
+frank.fn.log = frank.fn.logger = function(opt) {
+ this.middleware.push(connect.logger(opt));
+};
+
frank.fn.listen = function(port, msg) {
this.port = port;
msg = msg || "Frank is smoking at " + port;
@@ -50,6 +55,12 @@ frank.server = function() {
var self = this, server = this.server;
server.use(connect.favicon());
+ if (this.middleware.length) {
+ this.middleware.forEach(function(plugin, i) {
+ server.use(plugin);
+ });
+ }
+
Object.keys(this.handler).forEach(function(key) {
var handler = this.handler[key],
path = handler.path,
Please sign in to comment.
Something went wrong with that request. Please try again.