Class: Force::Middleware::InstanceURL

Inherits:
Force::Middleware show all
Defined in:
lib/force/middleware/instance_url.rb

Overview

Middleware which asserts that the instance_url is always set

Instance Method Summary collapse

Methods inherited from Force::Middleware

#client, #connection, #initialize

Constructor Details

This class inherits a constructor from Force::Middleware

Instance Method Details

#call(env) ⇒ Object


4
5
6
7
8
# File 'lib/force/middleware/instance_url.rb', line 4

def call(env)
  # If the connection url_prefix isn't set, we must not be authenticated.
  raise Force::UnauthorizedError, 'Connection prefix not set' unless url_prefix_set?
  @app.call(env)
end

#url_prefix_set?Boolean

Returns:

  • (Boolean)

10
11
12
# File 'lib/force/middleware/instance_url.rb', line 10

def url_prefix_set?
  !!(connection.url_prefix && connection.url_prefix.host)
end