Put request handler on SimpleServer.prototype (#2627)

The request handler may be used by ExpressJS apps directly and can do most of the heavy lifting without any modification. Note that the self variable must be assignee using `[Function].bind(null,SimpleServer instance)`.
print-window-tiddler
Arlen22 2016-12-17 10:06:10 -05:00 zatwierdzone przez Jeremy Ruston
rodzic a2fe101848
commit 1530b3e2d8
1 zmienionych plików z 48 dodań i 46 usunięć

Wyświetl plik

@ -91,10 +91,9 @@ SimpleServer.prototype.checkCredentials = function(request,incomingUsername,inco
}
};
SimpleServer.prototype.listen = function(port,host) {
var self = this;
http.createServer(function(request,response) {
SimpleServer.prototype.requestHandler = function(request,response) {
// Compose the state object
var self = this;
var state = {};
state.wiki = self.wiki;
state.server = self;
@ -141,7 +140,10 @@ SimpleServer.prototype.listen = function(port,host) {
});
break;
}
}).listen(port,host);
};
SimpleServer.prototype.listen = function(port,host) {
http.createServer(this.requestHandler.bind(this)).listen(port,host);
};
var Command = function(params,commander,callback) {