lib/herbert/Ajaxify.rb in herbert-0.0.6 vs lib/herbert/Ajaxify.rb in herbert-0.0.7
- old
+ new
@@ -29,11 +29,11 @@
custom.each {|name, value|
value = [value] unless value.is_a?(Array)
Headers[name] = (Headers[name] || []) | value
}
else
- log.h_info("File #{path} doesn't exists; no addition headers loaded")
+ log.h_info("File #{path} doesn't exists; no additional headers loaded")
end
app.before do
# Add the headers to the response
Headers.each {|name, value|
@@ -42,20 +42,28 @@
(val.is_a?(Proc) ? val.call : val).to_s
}
response[name] = value.join(', ')
}
end
-
- # Proxy for not CORS enables services such as
+
+ # enable OPTIONS verb
+ class << Sinatra::Base
+ def http_options path, opts={}, &block
+ route 'OPTIONS', path, opts, &block
+ end
+ end
+ Sinatra::Delegator.delegate :http_options
+
+ # Proxy for not CORS enabled services such as
# Google Maps
# /proxy/url?=
app.get '/proxy/' do
- url = URI.parse(URI.encode(params[:url]))
- res = Net::HTTP.start(url.host, 80) {|http|
- http.get(url.path + '?' + url.query)
- }
- response['content-type'] = res['content-type']
- res.body
- end
+ url = URI.parse(URI.encode(params[:url]))
+ res = Net::HTTP.start(url.host, 80) {|http|
+ http.get(url.path + '?' + url.query)
+ }
+ response['content-type'] = res['content-type']
+ res.body
+ end
end
- end
+ end
end
\ No newline at end of file