Created
October 14, 2011 10:16
-
-
Save linus/1286740 to your computer and use it in GitHub Desktop.
Matching POSTed data for artemma
This file contains 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 http = require("http"); | |
// Responses for various urls | |
var responses = { | |
"/createUser": "foo", | |
"/deleteUser": "bar" | |
}; | |
var server = http.createServer(function(req, res) { | |
// Listen for data on request | |
var body = ""; | |
req.on("data", function(chunk) { | |
body += chunk; | |
}); | |
req.on("end", function() { | |
res.writeHead(200, { "content-type": "text/plain" }); | |
if(body.match(/somethingcool/)) { | |
res.end(responses[req.url]); | |
} else { | |
res.end("err"); | |
} | |
}); | |
}); | |
server.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment