Class: Restforce::Middleware::InstanceURL

Inherits:
Restforce::Middleware show all
Defined in:
lib/restforce/middleware/instance_url.rb

Overview

Middleware which asserts that the instance_url is always set

Instance Method Summary collapse

Methods inherited from Restforce::Middleware

#client, #connection, #initialize

Constructor Details

This class inherits a constructor from Restforce::Middleware

Instance Method Details

#call(env) ⇒ Object


6
7
8
9
10
11
12
13
14
# File 'lib/restforce/middleware/instance_url.rb', line 6

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

  @app.call(env)
end

#url_prefix_set?Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/restforce/middleware/instance_url.rb', line 16

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