Module: Diversion::Encode::Json
- Included in:
- Diversion::Encode
- Defined in:
- lib/diversion/encode/json.rb
Class Method Summary collapse
Class Method Details
.get_url(attrs, options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/diversion/encode/json.rb', line 9 def get_url(attrs, ) # raw json json_raw = attrs.to_json # build json (slightly lighter than ruby hash) json = Url::encode_url(json_raw) # if we are signing the url then generate the signature sig = Signing::sign_data([:sign_key], [:sign_length], json_raw) sig = "-#{sig}" unless sig.empty? # get url and include port if needed unless [:port] == 80 url = "#{[:host]}:#{[:port]}#{[:path]}#{json}#{sig}" else url = "#{[:host]}#{[:path]}#{json}#{sig}" end url end |