Skip to content

Instantly share code, notes, and snippets.

@jfhbrook jfhbrook/boss.js
Created Sep 23, 2012

Embed
What would you like to do?
I want this. I haven't written it yet. Have you?
var ptth = require('ptth'),
express = require('express');
var lackeys = [];
express.use(ptth.boss({
mount: '/ptth',
}, function (lackey) {
lackeys.push(lackey);
}));
express.use(function (req, res, next) {
if (lackeys.length) {
lackey = lackeys.shift();
lackeys.push(lackey);
return lackey(req, res);
}
res.statusCode = 404;
res.end(JSON.stringify({
code: 404,
message: 'not found'
});
});
express.listen(8080);
var ptth = require('ptth');
ptth.connect('http://localhost:8080/ptth', function (req, res) {
res.setHeader('content-type', 'text/plain');
res.end('hello world!\n');
});
$ curl localhost:8080
hello world!
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.