aboutsummaryrefslogtreecommitdiffstats
path: root/src/nodejs/response.js
diff options
context:
space:
mode:
authorslomo <steve.harrison@gmx.net>2011-01-22 13:07:19 +0100
committerslomo <steve.harrison@gmx.net>2011-01-22 13:07:19 +0100
commit35778e6742567d38d349ca358cc5068cc0db1232 (patch)
tree14e9bc3b96ffc11f6611e2a715dee4f183f02805 /src/nodejs/response.js
parent75c6613097ca25055c8830876a2997b5d28beb21 (diff)
downloadosm-xapi-35778e6742567d38d349ca358cc5068cc0db1232.tar.gz
osm-xapi-35778e6742567d38d349ca358cc5068cc0db1232.tar.xz
osm-xapi-35778e6742567d38d349ca358cc5068cc0db1232.zip
first working version with new osmResponse objects
Diffstat (limited to 'src/nodejs/response.js')
-rw-r--r--src/nodejs/response.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/nodejs/response.js b/src/nodejs/response.js
new file mode 100644
index 0000000..47fb170
--- /dev/null
+++ b/src/nodejs/response.js
@@ -0,0 +1,35 @@
+exports.mkJsonRes = function mkJsonRes(res){
+ res.started = false;
+ res.atStart = function (){
+ if(!this.started){
+ this.writeHead(200);
+ this.write('json start start');
+ this.started = true;
+ }
+ }
+ res.atEnd = function(){
+ if(!this.started){
+ this.atStart(pojo);
+ }
+ this.write('json enden');
+ this.end();
+ }
+ res.putNode = function (pojo){
+ if(!this.started){
+ this.atStart(pojo);
+ }
+ this.write(JSON.stringify(pojo));
+ }
+
+ res.endWith500 = function(){
+ this.writeHead(500);
+ this.end();
+ }
+ return res;
+}
+
+exports.mkXmlRes = function (res){
+ return exports.mkJsonRes(res);
+}
+
+