/*****************************************
* Server
*****************************************
* Author: mikael.lofjard@gmail.com
* Website: http://lofjard.se
* License: MIT License
****************************************/
var
Server = (
function
() {
http = require(
'http'
);
options = {};
httpPort = 8080;
return
{
init:
(serverConfig) {
httpPort = serverConfig.httpPort || httpPort;
},
start:
(routerCallback) {
onRequest(request, response) {
if
(
typeof
(request.headers[
'host'
]) !=
'undefined'
) {
routerCallback(request, response);
}
else
// Give 400 Bad Request if no Host header field exists
response.writeHead(400);
response.end();
;
http.createServer(onRequest).listen(httpPort);
console.log(
'Server: Running at http://localhost:'
+ httpPort);
};
}());
(exports) !=
? exports.Server = Server :
null
/*****************************************
* Server
*****************************************
* Author: mikael.lofjard@gmail.com
* Website: http://lofjard.se
* License: MIT License
****************************************/
var
Server = (
function
() {
var
http = require(
'http'
);
var
options = {};
var
httpPort = 8080;
return
{
init:
function
(serverConfig) {
httpPort = serverConfig.httpPort || httpPort;
},
start:
function
(routerCallback) {
function
onRequest(request, response) {
if
(
typeof
(request.headers[
'host'
]) !=
'undefined'
) {
routerCallback(request, response);
}
else
{
// Give 400 Bad Request if no Host header field exists
response.writeHead(400);
response.end();
return
;
}
}
http.createServer(onRequest).listen(httpPort);
console.log(
'Server: Running at http://localhost:'
+ httpPort);
}
};
}());
typeof
(exports) !=
'undefined'
? exports.Server = Server :
null
;