Permalink
Browse files

added create feed route to the worker

  • Loading branch information...
robrighter committed May 25, 2010
1 parent b47ebbc commit c8f2a2f68518342c26dd191b2b75d782553476cd
Showing with 11 additions and 5 deletions.
  1. +11 −5 worker.js
View
@@ -11,21 +11,27 @@ var validhash = '.[0-9A-Za-z_\-]*';
var buffersize = 15;
var feeds = {};
-sys.puts("The uuid is: " +uuid.getUuid());
//Create a feed
server.get("__create", function (req, res, match) {
- //grab the hash from the query string
- feeds[hash] = new lpb.LongPollingBuffer(buffersize);
- return {status : "success"}
+ //grab the hash from the query string
+ var hash;
+ if(url.parse(req.url,true).hasOwnProperty('query') && url.parse(req.url,true).query.hasOwnProperty('hash')){
+ hash = parseInt(url.parse(req.url,true)['query']['hash']);
+ feeds[hash] = new lpb.LongPollingBuffer(buffersize);
+ return {status : "success"}
+ }
+ else {
+ return {status:'error', message:'must provide a hash for the feed to be created'};
+ }
});
//Get updates on a feed
server.get(new RegExp("^/latest/("+validhash+")$"), function (req, res, match) {
//first check to verify that the feed exists
if(!feeds.hasOwnProperty(match)){
- return {error:'true', message:'invalid feed identifier'};
+ return {status:'error', message:'invalid feed identifier'};
}
buffer = feeds[match];

0 comments on commit c8f2a2f

Please sign in to comment.