From 2fee9660afb9affc3c225f426e938ed5cde76e6b Mon Sep 17 00:00:00 2001 From: Miciah Masters Date: Thu, 31 Mar 2016 18:16:11 -0400 Subject: [PATCH] controller: default to JSON for REST API If no request format is specified for an REST API call, default to responding with JSON. This commit fixes bug 1322543. https://bugzilla.redhat.com/show_bug.cgi?id=1322543 --- controller/lib/openshift/controller/api_behavior.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controller/lib/openshift/controller/api_behavior.rb b/controller/lib/openshift/controller/api_behavior.rb index cd7b164d566..443b9a55994 100644 --- a/controller/lib/openshift/controller/api_behavior.rb +++ b/controller/lib/openshift/controller/api_behavior.rb @@ -8,11 +8,16 @@ module ApiBehavior included do before_filter ->{ Mongoid.identity_map_enabled = true } + before_filter :default_format_json end protected attr :requested_api_version + def default_format_json + request.format ||= 'json' + end + def check_version version = catch(:version) do "#{request.accept},#{request.env['CONTENT_TYPE']}".split(',').each do |mime_type|