Mercurial > psgxs
view modules/mod_http.js @ 34:dcf1f09f8cee
Add message to publish module and various fixes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 05 Nov 2010 15:31:13 +0100 |
parents | 62cbb1c49bc5 |
children | bc717575e66a |
line wrap: on
line source
var config = require('../configuration'); var http = require('http'); var files = require('fs').readdirSync('modules/http'); var regex = /^mod_.*\.js/; var sites = {}; for (var i in files) { var file = files[i]; if (!regex.test(file)) continue; var module = require('./http/' + files[i]); for (var j in module) { if (typeof sites[j] != 'undefined') console.log('WARNING: module '+j+' already loaded.'); sites[j] = module[j]; } } http.createServer(function (req, res) { var sent = false; for (var i in sites) { var site = sites[i]; if (!site.url.test(req.url)) continue; sent = site.func(req, res); return; } if (!sent) { res.writeHead(404, {'Content-Type': 'text/plain'}); res.end('Error 404'); } }).listen(8484);