deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/7] git commit: Core: Consolidated Rack::Accept loading
Date Wed, 12 Sep 2012 07:35:34 GMT
Core: Consolidated Rack::Accept loading

Added all necesary middleware to Rack::Accept 'self.registred' method. Now all
requires for the 'respond_to' method are loaded when 'register Rack::RespondTo'
is called.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/17b218b9
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/17b218b9
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/17b218b9

Branch: refs/heads/master
Commit: 17b218b91764a0f942828c8d31e6bf2487b5aa8c
Parents: 79da91b
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Mon Sep 10 11:15:29 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Wed Sep 12 09:35:52 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/helpers.rb        |    1 -
 server/lib/cimi/server.rb         |    2 --
 server/lib/deltacloud/helpers.rb  |    1 -
 server/lib/deltacloud/server.rb   |    2 --
 server/lib/sinatra/rack_accept.rb |    9 +++++++--
 5 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/17b218b9/server/lib/cimi/helpers.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers.rb b/server/lib/cimi/helpers.rb
index bf268f8..31f8d51 100644
--- a/server/lib/cimi/helpers.rb
+++ b/server/lib/cimi/helpers.rb
@@ -51,7 +51,6 @@ module CIMI::Collections
     helpers Deltacloud::Helpers::Drivers
     helpers Sinatra::AuthHelper
     helpers Sinatra::UrlForHelper
-    helpers Rack::RespondTo::Helpers
     helpers Deltacloud::Helpers::Application
     helpers CIMIHelper
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/17b218b9/server/lib/cimi/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index cbb6486..88fc5d0 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -36,8 +36,6 @@ module CIMI
     use Rack::ETag
     use Rack::MatrixParams
     use Rack::DriverSelect
-    use Rack::Accept
-    use Rack::MediaType
 
     helpers CIMIHelper
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/17b218b9/server/lib/deltacloud/helpers.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers.rb b/server/lib/deltacloud/helpers.rb
index 872c239..c065e64 100644
--- a/server/lib/deltacloud/helpers.rb
+++ b/server/lib/deltacloud/helpers.rb
@@ -30,7 +30,6 @@ module Deltacloud::Collections
     helpers Deltacloud::Helpers::Drivers
     helpers Sinatra::AuthHelper
     helpers Sinatra::UrlForHelper
-    helpers Rack::RespondTo::Helpers
     helpers Deltacloud::Helpers::Application
 
     register Rack::RespondTo

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/17b218b9/server/lib/deltacloud/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
index fcd24d9..c7c6c41 100644
--- a/server/lib/deltacloud/server.rb
+++ b/server/lib/deltacloud/server.rb
@@ -37,8 +37,6 @@ module Deltacloud
     use Rack::Date
     use Rack::ETag
     use Rack::DriverSelect
-    use Rack::Accept
-    use Rack::MediaType
 
     include Deltacloud::Helpers
     include Deltacloud::Collections

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/17b218b9/server/lib/sinatra/rack_accept.rb
----------------------------------------------------------------------
diff --git a/server/lib/sinatra/rack_accept.rb b/server/lib/sinatra/rack_accept.rb
index 6b77fa8..3be919c 100644
--- a/server/lib/sinatra/rack_accept.rb
+++ b/server/lib/sinatra/rack_accept.rb
@@ -23,6 +23,9 @@ module Rack
     # We need to overide the default render method to supply correct path to the
     # template, since Sinatra is by default looking in the current __FILE__ path
     def self.registered(app)
+      app.use Rack::Accept
+      app.use Rack::MediaType
+      app.helpers Rack::RespondTo::Helpers
       app.class_eval do
         alias :render_without_format :render
         def render(*args, &block)
@@ -48,12 +51,14 @@ module Rack
       # rack-accept middleware.
       def self.included(klass)
         klass.class_eval do
-          alias :content_type_without_save :content_type
+          alias_method :original_content_type, :content_type
+
           def content_type(*args)
-            content_type_without_save(*args)
+            original_content_type(*args)
             request.env['rack-accept.formats'] = { args.first.to_sym => 1 }
             response['Content-Type']
           end
+
         end
       end
 


Mime
View raw message