summaryrefslogtreecommitdiff
path: root/chef-server-api/app/controllers/application.rb
diff options
context:
space:
mode:
Diffstat (limited to 'chef-server-api/app/controllers/application.rb')
-rw-r--r--chef-server-api/app/controllers/application.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/chef-server-api/app/controllers/application.rb b/chef-server-api/app/controllers/application.rb
index 72c1482087..7141bf91e5 100644
--- a/chef-server-api/app/controllers/application.rb
+++ b/chef-server-api/app/controllers/application.rb
@@ -22,6 +22,7 @@
require "chef/mixin/checksum"
require "chef/cookbook_loader"
require "mixlib/authentication/signatureverification"
+require "chef/json"
class Application < Merb::Controller
@@ -102,11 +103,11 @@ class Application < Merb::Controller
def access_denied
raise Unauthorized, "You must authenticate first!"
end
-
+
def get_available_recipes
all_cookbooks_list = Chef::CookbookVersion.cdb_list(true)
available_recipes = all_cookbooks_list.sort{ |a,b| a.name.to_s <=> b.name.to_s }.inject([]) do |result, element|
- element.recipes.sort.each do |r|
+ element.recipes.sort.each do |r|
if r =~ /^(.+)::default$/
result << $1
else
@@ -118,5 +119,19 @@ class Application < Merb::Controller
available_recipes
end
+ # Fix CHEF-1292/PL-538; cause Merb to pass the max nesting constant into
+ # obj.to_json, which it calls by default based on the original request's
+ # accept headers and the type passed into Merb::Controller.display
+ #
+ # TODO: tim, 2010-11-24: would be nice to instead have Merb call
+ # Chef::JSON.to_json, instead of obj.to_json, but changing that
+ # behavior is convoluted in Merb. This override is assuming that
+ # Merb is eventually calling obj.to_json, which takes the :max_nesting
+ # option.
+ override! :display
+ def display(obj)
+ super(obj, nil, {:max_nesting => Chef::JSON::JSON_MAX_NESTING})
+ end
+
end