incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Lalancette <>
Subject [PATCH] Add the driver to URLs returned.
Date Fri, 03 Jun 2011 13:37:52 GMT
Currently when using a driver URL like:


The links that get returned for the collections look like:

<link rel='instances' href='/api/instances' />

However, that is not exactly right; the HREF should take
the driver into account, so you end up with:

<link rel='instances' href='/api;driver=ec2/instances' />

So that clients can do the right thing.

This patch fixes the problem by substituting in the REQUEST_URI
(which contains the driver, if any) in the url_for method.  This
seems to make things work for me.

Signed-off-by: Chris Lalancette <>
 server/lib/sinatra/url_for.rb |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/server/lib/sinatra/url_for.rb b/server/lib/sinatra/url_for.rb
index 60da0ef..990c49c 100644
--- a/server/lib/sinatra/url_for.rb
+++ b/server/lib/sinatra/url_for.rb
@@ -63,8 +63,14 @@ module Sinatra
       # Don't add the base fragment if url_for gets called more than once
       # per url or the url_fragment passed in is an absolute url
       if url_escape.match(/^#{base}/) or url_escape.match(/^http/)
+        # here, we assume that if any driver additions are needed, they have
+        # been done prior to entering this method.  Hence we just return the
+        # URL as-is
+        # one last thing we need to do here is to make sure we properly add
+        # the driver type to the URL (if necessary)
+        url_escape.sub!(/^\/api/, request.env['REQUEST_URI'])

View raw message