Skip to content
Snippets Groups Projects
Commit a8cdbcf4 authored by Matthew Rudy Jacobs's avatar Matthew Rudy Jacobs
Browse files

introduce `supported_protocols` as a place for lookups to override

avoid overriding `use_ssl?` or `protocol` directly
parent 4f8b5390
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,15 @@ module Geocoder
@cache
end
##
# Array containing the protocols supported by the api.
# Should be set to [:http] if only HTTP is supported
# or [:https] if only HTTPS is supported.
#
def supported_protocols
[:http, :https]
end
private # -------------------------------------------------------------
##
......@@ -279,6 +288,9 @@ module Geocoder
end
def use_ssl?
return true if supported_protocols == [:https]
return false if supported_protocols == [:http]
configuration.use_https
end
......
......@@ -12,8 +12,8 @@ module Geocoder
["key"]
end
def use_ssl?
true
def supported_protocols
[:https]
end
def query_url(query)
......
......@@ -8,10 +8,10 @@ module Geocoder::Lookup
"MaxMind GeoIP2"
end
def use_ssl?
# Maxmind's GeoIP2 Precision Services only supports HTTPS,
# otherwise a `404 Not Found` HTTP response will be returned
true
# Maxmind's GeoIP2 Precision Services only supports HTTPS,
# otherwise a `404 Not Found` HTTP response will be returned
def supported_protocols
[:https]
end
def query_url(query)
......
......@@ -16,12 +16,13 @@ module Geocoder::Lookup
"#{protocol}://api.smartystreets.com/#{path}?#{url_query_string(query)}"
end
private # ---------------------------------------------------------------
def protocol
"https" # required by API as of 26 March 2015
# required by API as of 26 March 2015
def supported_protocols
[:https]
end
private # ---------------------------------------------------------------
def zipcode_only?(query)
!query.text.is_a?(Array) and query.to_s.strip =~ /\A\d{5}(-\d{4})?\Z/
end
......
......@@ -9,16 +9,16 @@ module Geocoder::Lookup
end
def query_url(query)
#currently doesn't support HTTPS
"http://www.telize.com/geoip/#{query.sanitized_text}"
end
private # ---------------------------------------------------------------
def use_ssl?
false
# currently doesn't support HTTPS
def supported_protocols
[:http]
end
private # ---------------------------------------------------------------
def results(query)
# don't look up a loopback address, just return the stored result
return [reserved_result(query.text)] if query.loopback_ip_address?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment