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
/** | |
* Given we have a regex with one more matching groups. | |
* The regex should capture those groups from an 'input' | |
* string and replace the matched values in an 'template' | |
* string. | |
* | |
* Example: | |
* regex: /([1-9]{8})/([1-9]{8})?/ | |
* input string: '/some-magic/path/12122211/22112211' | |
* template string: 'http://someurl?adId=$1&adId=$2' |
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 sys = require('sys'); | |
var path = require('path'); | |
var http = require('http'); | |
http.createServer(function(req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World!\n'); | |
console.log('servi'); | |
}).listen(1337, "localhost"); |
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
// This is a design doc for adding two methods to node via monkey patching | |
// that I find useful in all the little bits of HTTP glue I make. The point | |
// is to create a useful abstraction for forwarding requests and linking | |
// responses. In the most trivial case for building a reverse proxy, but | |
// see below for other use cases. | |
// API | |
http.ServerRequest.prototype.forward(port, host, dataFilter=null) | |
http.ServerResponse.prototype.attach(requestOrResponse, responseFilter=null, dataFilter=null) |
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 fs = require('fs'); | |
var url = require('url'); | |
var sys = require('sys'); | |
var http = require('http'); | |
require('./ejs'); // EJS, http://embeddedjs.com/ | |
/* | |
* Server-side controller methods | |
*/ |