incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH core 2/2] Rabbit: New Sinatra (1.3.0) has support for OPTIONS helper. So monkey patching is not needed there anymore
Date Thu, 06 Oct 2011 13:54:43 GMT
ACK  ... this is a very nice, as yet undocumented feature (we should 
remedy this as soon as the new site docs go up)

e.g. for rhevm driver:
=========
request:

curl -iv -X OPTIONS --user "user:password" 
http://localhost:3001/api/instances?format=xml

=========
response:

HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Date: Thu, 06 Oct 2011 13:49:42 GMT
X-Runtime: 0.002646
Content-Length: 0
Server: Apache-Deltacloud/0.4.1
X-Operations-Allowed: destroy,show,run,start,reboot,create,stop,index,new


marios

On 06/10/11 16:02, mfojtik@redhat.com wrote:
> From: Michal Fojtik<mfojtik@redhat.com>
>
>
> Signed-off-by: Michal fojtik<mfojtik@redhat.com>
> ---
>   server/lib/sinatra/rabbit.rb |   13 ++++++++-----
>   1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb
> index 00bd075..e83d5a8 100644
> --- a/server/lib/sinatra/rabbit.rb
> +++ b/server/lib/sinatra/rabbit.rb
> @@ -423,11 +423,14 @@ module Sinatra
>     helpers RabbitHelper
>   end
>
> -configure do
> -  class<<  Sinatra::Base
> -    def options(path, opts={},&block)
> -      route 'OPTIONS', path, opts,&block
> +# In Sinatra<  1.2 there was no helper to create OPTIONS route
> +unless Sinatra::Base.respond_to? :options
> +  configure do
> +    class<<  Sinatra::Base
> +      def options(path, opts={},&block)
> +        route 'OPTIONS', path, opts,&block
> +      end
>       end
> +    Sinatra::Delegator.delegate :options
>     end
> -  Sinatra::Delegator.delegate :options
>   end


Mime
View raw message