From f1eed600d5ad0dcb8e3a163352a5d7fe948e83ed Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:20:42 +0100 Subject: [PATCH] Adds routes document (WIP) --- docs/Routes.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 docs/Routes.md diff --git a/docs/Routes.md b/docs/Routes.md new file mode 100644 index 00000000..314f175d --- /dev/null +++ b/docs/Routes.md @@ -0,0 +1,123 @@ +This document list all routes available in Windshaft-cartodb Maps API server. + +## Routes list + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y@:scale_factor?x.:format {:token(f),:z(f),:x(f),:y(f),:scale_factor(t),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y.:format {:token(f),:z(f),:x(f),:y(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/:z/:x/:y.(:format) {:token(f),:layer(f),:z(f),:x(f),:y(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/attributes/:fid {:token(f),:layer(f),:fid(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/static/center/:token/:z/:lat/:lng/:width/:height.:format {:token(f),:z(f),:lat(f),:lng(f),:width(f),:height(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format {:token(f),:west(f),:south(f),:east(f),:north(f),:width(f),:height(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET / {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /version {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id/jsonp {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template) {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/infowindow {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/map_metadata {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /health {} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `POST /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map/named|/tiles/template) {} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE /tiles/:table/flush_cache {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `PUT (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +## How to generate the list of routes + +Something like the following patch should do the trick + +```javascript +diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js +index 477a4c2..f69eebb 100644 +--- a/lib/cartodb/cartodb_windshaft.js ++++ b/lib/cartodb/cartodb_windshaft.js +@@ -242,6 +242,20 @@ var CartodbWindshaft = function(serverOptions) { + } + }); + ++ var format = require('util').format; ++ var routesNotes = Object.keys(ws.routes.routes) ++ .map(function(method) { return ws.routes.routes[method]; }) ++ .reduce(function(previous, current) { current.map(function(r) { previous.push(r) }); return previous;}, []) ++ .map(function(route) { ++ return format("\n1. `%s %s {%s} (%d)`\n
Notes: [DEPRECATED]? ", ++ route.method.toUpperCase(), ++ route.path, ++ route.keys.map(function(k) { return format(':%s(%s)', k.name, k.optional ? 't' : 'f'); } ).join(','), ++ route.callbacks.length ++ ); ++ }); ++ console.log(routesNotes.join('\n')); ++ + return ws; + }; + + +``` \ No newline at end of file