Created
February 7, 2013 11:09
-
-
Save geNAZt/4730331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
vm = require('vm'), | |
app = express(), | |
vhosts = { | |
"www.house-of-code.org": vm.createContext({app: app, require: require}), | |
"test.house-of-code.org": vm.createContext({app: app, require: require}) | |
}; | |
var vhostWWW = vm.createScript("var express = require('express')," + | |
" vhostApp = express();" + | |
"vhostApp.get('/', function(req, res) {" + | |
" res.end('WWW');" + | |
"});" + | |
"app.use(express.vhost('www.house-of-code.org', vhostApp));"); | |
vhostWWW.runInContext(vhosts["www.house-of-code.org"]); | |
var vhostTest = vm.createScript("var express = require('express')," + | |
" vhostApp = express();" + | |
"vhostApp.get('/', function(req, res) {" + | |
" res.end('test'); throw new Error('test');" + | |
"});" + | |
"app.use(express.vhost('test.house-of-code.org', vhostApp));"); | |
vhostTest.runInContext(vhosts["test.house-of-code.org"]); | |
app.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment