Skip to content

Instantly share code, notes, and snippets.

@victusfate
Forked from visnup/README.js
Created November 16, 2010 20:52
Show Gist options
  • Save victusfate/702496 to your computer and use it in GitHub Desktop.
Save victusfate/702496 to your computer and use it in GitHub Desktop.
var connect = require('connect')
, sys = require('sys');
var webapp = function(req, res) {
var path = req.url.split('/');
this[path[1]].apply(this, path.slice(2));
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(sys.inspect(this));
};
connect.createServer(webapp.bind([])).listen(8000);
// ^^^^^^^^^^^^^^^
// | (x)
// ROFLSCALE DB ---/
// http://localhost:8000/push/1 -> [ '1' ]
// http://localhost:8000/push/2 -> [ '1', '2' ]
// http://localhost:8000/push/3 -> [ '1', '2', '3' ]
// http://localhost:8000/toString -> [ '1', '2', '3' ]
// http://localhost:8000/pop -> [ '1', '2' ]
// http://localhost:8000/shift -> [ '2' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment