From a6df6ab0a7f13879ee57e8a0ce5654dda62dee2d Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 8 Aug 2011 20:14:01 +0100 Subject: [PATCH] change api calls from POST to GET --- node/server.js | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/node/server.js b/node/server.js index 7b8cec6c..8764be8a 100644 --- a/node/server.js +++ b/node/server.js @@ -243,37 +243,23 @@ async.waterfall([ var apiLogger = log4js.getLogger("API"); //This is a api call, collect all post informations and pass it to the apiHandler - app.all('/api/1/:func', function(req, res) + app.get('/api/1/:func', function(req, res) { res.header("Server", serverName); - //check if this is a post request - if(req.method == "POST") + apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(req.query)); + + //wrap the send function so we can log the response + res._send = res.send; + res.send = function(response) { - new formidable.IncomingForm().parse(req, function(err, fields, files) - { - if(err) throw err; - - apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(fields)); - - //wrap the send function so we can log the response - res._send = res.send; - res.send = function(response) - { - response = JSON.stringify(response); - apiLogger.info("RESPONSE, " + req.params.func + ", " + response); - res._send(response); - } - - //call the api handler - apiHandler.handle(req.params.func, fields, req, res); - }); - } - //say goodbye if this is not a post request - else - { - res.send({code: 5, message: "no POST request", data: null}); + response = JSON.stringify(response); + apiLogger.info("RESPONSE, " + req.params.func + ", " + response); + res._send(response); } + + //call the api handler + apiHandler.handle(req.params.func, req.query, req, res); }); //The Etherpad client side sends information about how a disconnect happen