Class: Stream::APIURLGenerator
- Inherits:
-
URLGenerator
- Object
- URLGenerator
- Stream::APIURLGenerator
- Defined in:
- lib/stream/url.rb
Instance Attribute Summary
Attributes inherited from URLGenerator
Instance Method Summary collapse
-
#initialize(options) ⇒ APIURLGenerator
constructor
A new instance of APIURLGenerator.
Constructor Details
#initialize(options) ⇒ APIURLGenerator
Returns a new instance of APIURLGenerator.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/stream/url.rb', line 9 def initialize() super() @options = location = make_location([:location]) location ||= 'api' api_version = [:api_version] || 'v1.0' if ENV.fetch('STREAM_URL', nil) uri = URI.parse(ENV.fetch('STREAM_URL')) scheme = uri.scheme host = uri.host port = uri.port else scheme = 'https' host = [:api_hostname] port = 443 end unless ENV.fetch('STREAM_URL', nil) =~ /localhost/ host_parts = host.split('.') host = host_parts.slice(1..-1).join('.') if host_parts.length == 3 host = "#{location}.#{host}" if location end @base_path = "/api/#{api_version}" @url = "#{scheme}://#{host}:#{port}#{@base_path}" end |