Skip to content

Commit

Permalink
added option for connect.vhost
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Mar 21, 2013
1 parent 4c4bc2e commit f178c47
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions bin/demo.js
Expand Up @@ -2,15 +2,19 @@
(function () {
"use strict";

var providerPort = process.argv[2] || 4455
var connect = require('connect')
, providerPort = process.argv[2] || 4455
, consumerPort = process.argv[3] || 7788
, juntosPort = process.argv[2] || 80
, appProvider = require('../bookface-provider')
, appConsumer = require('../blogthing-consumer')
;

function run() {
function run(opts) {
var providerServer
, consumerServer
, app
, server
;

function onProviderListening() {
Expand All @@ -27,11 +31,33 @@
console.log("Open your browser to Blogthing Consumer at http://%s:%d", addr.address, addr.port);
}

providerServer = appProvider.listen(providerPort, onProviderListening);
consumerServer = appConsumer.listen(consumerPort, onConsumerListening);
function onListening() {
console.log("Open your browser to Blogthing Consumer at http://consumer.example.net");
console.log("Open your browser to Bookface Provider at http://provider.example.com");
}

if (opts.losDos) {
providerServer = appProvider.listen(providerPort, onProviderListening);
consumerServer = appConsumer.listen(consumerPort, onConsumerListening);
} else {
// something is really screwy with connect.vhost and this example
// ... it's not working at all
app = connect.createServer();
app.use(connect.vhost('provider.example.com', appProvider));
app.use(connect.vhost('consumer.example.net', appConsumer));
app.use(function (req, res, next) {
console.log('req.headers.host', req.headers.host);
next();
});
server = app.listen(juntosPort, onListening);
}
}

if (require.main === module) {
run();
if (true) {
run({ losDos: true });
} else {
run();
}
}
}());

0 comments on commit f178c47

Please sign in to comment.