lib/jsonatra.rb in jsonatra-1.0.4 vs lib/jsonatra.rb in jsonatra-1.0.5
- old
+ new
@@ -50,19 +50,10 @@
disable :protection
end
before do
- # default to Content-Type to JSON, or javascript if request is JSONP
- #
- content_type :json
- unless params[:callback].nil? or params[:callback] == ''
- halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
- response.jsonp_callback = params[:callback]
- content_type :js
- end
-
# grok access control headers
#
achs = begin
self.access_control_headers
rescue NoMethodError
@@ -76,9 +67,18 @@
end
# allow origin, oauth from everywhere
#
achs.each {|k,v| headers[k] = v}
+
+ # default to Content-Type to JSON, or javascript if request is JSONP
+ #
+ content_type :json
+ unless params[:callback].nil? or params[:callback] == ''
+ halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
+ response.jsonp_callback = params[:callback]
+ content_type :js
+ end
end
after do
if settings.respond_to? :camelcase_error_types? and settings.camelcase_error_types?