diff options
author | Mark Engel <mark.c.engel@gmail.com> | 2011-01-28 17:04:12 +0100 |
---|---|---|
committer | Mark Engel <mark.c.engel@gmail.com> | 2011-01-28 17:04:12 +0100 |
commit | 5df2c8b916bf8845042be1f9df4656cd13a3ddbe (patch) | |
tree | 8ae6d83cdd87dcdb058c85ce33e566a09752483d /src | |
parent | 52531bb1553a7e3a288465a68284192f4fbba18c (diff) | |
parent | 243fa3e0193b270deb1614bb0b7e0e8e62afc4ad (diff) | |
download | osm-xapi-5df2c8b916bf8845042be1f9df4656cd13a3ddbe.tar.gz osm-xapi-5df2c8b916bf8845042be1f9df4656cd13a3ddbe.tar.xz osm-xapi-5df2c8b916bf8845042be1f9df4656cd13a3ddbe.zip |
Merge branch 'master' of github.com:slomo/osm-spline-xapi
Diffstat (limited to 'src')
-rw-r--r-- | src/nodejs/config.json | 13 | ||||
-rw-r--r-- | src/nodejs/main.js | 1 | ||||
-rw-r--r-- | src/nodejs/response.js | 4 | ||||
-rw-r--r-- | src/nodejs/xmlGenerator.js | 16 |
4 files changed, 28 insertions, 6 deletions
diff --git a/src/nodejs/config.json b/src/nodejs/config.json index 92b4484..2ea4352 100644 --- a/src/nodejs/config.json +++ b/src/nodejs/config.json @@ -1,7 +1,12 @@ { - "connectionString": "pg://user:password@host/database", - "host": "localhost", - "port": 8080, - "logLevel": "ERROR" + "connectionString" : "pg://user:password@host/database", + "host" : "localhost", + "port" : 8080, + "logLevel" : "ERROR", + "version" : 0.6, + "copyright" : "2011 OpenStreetMap contributers", + "instance" : "node xapi", + "generator" : "xapi: OSM Extended API", + "namespace" : "http://localhost/xapi/0.6" } diff --git a/src/nodejs/main.js b/src/nodejs/main.js index e907f03..4411081 100644 --- a/src/nodejs/main.js +++ b/src/nodejs/main.js @@ -254,6 +254,7 @@ function getConfig(configPath, callback) { function init(newConfig) { config = newConfig; + xmlGenerator.config = config; log.setLevel(config.logLevel); log.info("server starting..."); log.info("loaded config from " + configPath); diff --git a/src/nodejs/response.js b/src/nodejs/response.js index b7fdd85..4be4df0 100644 --- a/src/nodejs/response.js +++ b/src/nodejs/response.js @@ -35,7 +35,7 @@ exports.mkXmlRes = function (res){ res.atStart = function (){ if(!this.started){ this.writeHead(200); - this.write('<xml>'); + this.write(xmlGen.createHeader()); this.started = true; } } @@ -43,7 +43,7 @@ exports.mkXmlRes = function (res){ if(!this.started){ this.atStart(); } - this.write('</xml>'); + this.write('</osm>'); this.end(); } res.putWay = function (pojo){ diff --git a/src/nodejs/xmlGenerator.js b/src/nodejs/xmlGenerator.js index 258cb18..a477457 100644 --- a/src/nodejs/xmlGenerator.js +++ b/src/nodejs/xmlGenerator.js @@ -1,3 +1,5 @@ +var config; + var builder = require('xmlbuilder'); //set up logger var log4js = require('log4js')(); //note the need to call the function @@ -48,3 +50,17 @@ exports.createWay = function (row) { return builder.toString({pretty:'true'}); }; +//header for xml response with information about xapi instance... +exports.createHeader = function createHeader() { + var header = "<?xml version='1.0' standalone='no'?>"; + var tmp = builder.begin('osm') + .att('version',this.config.version) + .att('generator',this.config.generator) + .att('xmlns:xapi',this.config.namespace) + .att('xapi:uri','') + .att('xapi:planetDate','') + .att('xapi:copyright',this.config.copyright) + .att('xapi:instance',this.config.instance); + header = header + tmp.toString(); + return header.substr(0,header.length-2) + " >"; +} |