Module: MapLayers::Proxy

Defined in:
lib/map_layers/georss.rb

Overview

Remote http Proxy

Instance Method Summary collapse

Instance Method Details

#proxyObject

Proxy for accessing remote files like GeoRSS, which is not allowed directly from the browser


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/map_layers/georss.rb', line 94

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


88
89
90
91
# File 'lib/map_layers/georss.rb', line 88

def register_remote_url(url)
  session[:proxy_url] ||= []
  session[:proxy_url] << url      
end