Permalink
Browse files

[fix] be sure to close request to example service event with invalid …

…http verbs
  • Loading branch information...
1 parent 379be87 commit c4a8bba20ea53315065240fff68a4fe41ad101b2 @bmeck bmeck committed Nov 7, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 example/webservice.js
View
@@ -160,25 +160,35 @@ var server = http.createServer(function validateRestRequest (req, res) {
// values
//
switch (req.method) {
+
case "GET":
res.writeHead(200);
var result = storedValue.body;
res.end(JSON.stringify(result));
return;
+
case "POST":
res.writeHead(201);
res.end();
memoryStore[requestBody.url] = requestBody;
return;
+
case "DELETE":
delete memoryStore[requestBody.url];
res.writeHead(200);
res.end();
return;
+
case "PUT":
memoryStore[requestBody.url] = requestBody;
res.writeHead(200);
res.end();
+ return;
+
+ default:
+ res.writeHead(400);
+ res.end('Invalid Http Verb');
+ return;
}
});
})

0 comments on commit c4a8bba

Please sign in to comment.