Module: UrlSigner
- Defined in:
- lib/google_maps_embed/url_signer.rb
Overview
Signing the URL allows google to verify that any site using your API key has been authorized to do so. Signing the URL is not required, but is highly recommended. This code is originally from googlemaps.github.io/url-signing/index.html
Class Method Summary collapse
Class Method Details
.sign(url, key) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/google_maps_embed/url_signer.rb', line 13 def sign(url, key) parsed_url = URI.parse(url) full_path = "#{parsed_url.path}?#{parsed_url.query}" signature = generate_signature(full_path, key) "#{parsed_url.scheme}://#{parsed_url.host}#{full_path}&signature=#{signature}" end |