mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +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:
parent
a2fe101848
commit
1530b3e2d8
@ -91,10 +91,9 @@ SimpleServer.prototype.checkCredentials = function(request,incomingUsername,inco
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SimpleServer.prototype.listen = function(port,host) {
|
SimpleServer.prototype.requestHandler = function(request,response) {
|
||||||
var self = this;
|
|
||||||
http.createServer(function(request,response) {
|
|
||||||
// Compose the state object
|
// Compose the state object
|
||||||
|
var self = this;
|
||||||
var state = {};
|
var state = {};
|
||||||
state.wiki = self.wiki;
|
state.wiki = self.wiki;
|
||||||
state.server = self;
|
state.server = self;
|
||||||
@ -141,7 +140,10 @@ SimpleServer.prototype.listen = function(port,host) {
|
|||||||
});
|
});
|
||||||
break;
|
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) {
|
var Command = function(params,commander,callback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user