Skip to content

Commit a2d4ee4

Browse files
committed
Merge pull request #1 from AbleTech/feature/content_type_changes
Feature/content type changes
2 parents d28d101 + 0f63585 commit a2d4ee4

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/easy/api/controller_methods.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@ module InstanceMethods
44
# Renders the Easy::Api::Result object in either json or html format (can be extended to include other formats)
55
def render_format
66
respond_to do |format|
7-
format.html { render :status => @result.status_code }
8-
format.xml { render :xml => @result.to_xml(:root => 'response', :skip_types => true), :status => @result.status_code }
9-
format.json { render :json => @result, :status => (params[:callback].present? ? 200 : @result.status_code), :callback => params[:callback] }
7+
format.html do
8+
render :status => @result.status_code
9+
end
10+
11+
format.xml do
12+
render :xml => @result.to_xml(:root => 'response', :skip_types => true), :status => @result.status_code
13+
end
14+
15+
format.json do
16+
if params[:callback].present?
17+
status = 200
18+
content_type = 'application/javascript'
19+
else
20+
status = @result.status_code
21+
content_type = 'application/json'
22+
end
23+
24+
render :json => @result, :status => status, :callback => params[:callback], :content_type => content_type
25+
end
1026
end
1127
end
1228

lib/easy/api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Easy
22
module Api
3-
VERSION = "0.1.2"
3+
VERSION = "0.1.3"
44
end
55
end

0 commit comments

Comments
 (0)