1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00

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)`.
This commit is contained in:
Arlen22 2016-12-17 10:06:10 -05:00 committed by Jeremy Ruston
parent a2fe101848
commit 1530b3e2d8

View File

@ -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) {