]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/geocoder_controller.rb
Testing, testing, testing...
[rails.git] / app / controllers / geocoder_controller.rb
index be4f0570c828c298dedda67fd3446a0aed5686bd..11460f8c0aa5363f842f46a591d3767e0e3b9929 100644 (file)
@@ -3,7 +3,6 @@
 class GeocoderController < ApplicationController
   require "cgi"
   require "uri"
-  require "net/http"
   require "rexml/document"
 
   before_action :authorize_web
@@ -186,9 +185,9 @@ class GeocoderController < ApplicationController
     end
 
     render :action => "results"
-    #  rescue StandardError => ex
-    #    @error = "Error contacting nominatim.openstreetmap.org: #{ex.to_s}"
-    #    render :action => "error"
+  rescue StandardError => ex
+    @error = "Error contacting nominatim.openstreetmap.org: #{ex}"
+    render :action => "error"
   end
 
   def search_geonames
@@ -218,7 +217,7 @@ class GeocoderController < ApplicationController
 
     render :action => "results"
   rescue StandardError => ex
-    @error = "Error contacting ws.geonames.org: #{ex}"
+    @error = "Error contacting api.geonames.org: #{ex}"
     render :action => "error"
   end
 
@@ -280,14 +279,14 @@ class GeocoderController < ApplicationController
 
     render :action => "results"
   rescue StandardError => ex
-    @error = "Error contacting ws.geonames.org: #{ex}"
+    @error = "Error contacting api.geonames.org: #{ex}"
     render :action => "error"
   end
 
   private
 
   def fetch_text(url)
-    Net::HTTP.get(URI.parse(url))
+    OSM.http_client.get(URI.parse(url)).body
   end
 
   def fetch_xml(url)