Module: MapLayers::Proxy
- Defined in:
- lib/map_layers.rb
Overview
Remote http Proxy
Instance Method Summary collapse
-
#proxy ⇒ Object
Proxy for accessing remote files like GeoRSS, which is not allowed directly from the browser.
-
#register_remote_url(url) ⇒ Object
Register an url, before the proxy is called.
Instance Method Details
#proxy ⇒ Object
Proxy for accessing remote files like GeoRSS, which is not allowed directly from the browser
326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/map_layers.rb', line 326 def proxy if session[:proxy_url].nil? || !session[:proxy_url].include?(params["url"]) logger.warn "Proxy request not in session: #{params["url"]}" render :nothing => true return end url = URI.parse(URI.encode(params[:url])) logger.debug "Proxy request for #{url.scheme}://#{url.host}#{url.path}" result = Net::HTTP.get_response(url) render :text => result.body, :status => result.code, :content_type => "text/xml" end |
#register_remote_url(url) ⇒ Object
Register an url, before the proxy is called
320 321 322 323 |
# File 'lib/map_layers.rb', line 320 def register_remote_url(url) session[:proxy_url] ||= [] session[:proxy_url] << url end |