1 var url
= require('url'),
2 node_static
= require ('node-static');
4 var HTTPHandler = function (config
) {
5 this.static_file_server
= new StaticFileServer(config
.public_html
);
8 module
.exports
.HTTPHandler
= HTTPHandler
;
10 var StaticFileServer = function (public_html
) {
11 public_html
= public_html
|| 'client_backbone/';
12 this.fileServer
= new node_static
.Server(public_html
);
15 StaticFileServer
.prototype.serve = function (request
, response
) {
16 this.fileServer
.serve(request
, response
, function (err
) {
18 response
.writeHead(err
.status
, err
.headers
);
24 HTTPHandler
.prototype.handler = function (request
, response
) {
27 uri
= url
.parse(request
.url
, true);
28 subs
= uri
.pathname
.substr(0, 4);
30 if (uri
.pathname
.substr(0, 10) === '/socket.io') {
33 this.static_file_server
.serve(request
, response
);