Sha256: af4dcf9718d9071a2aab27c40a7726f49d9c31a71375fe318ba4592854e8d8c9
Contents?: true
Size: 892 Bytes
Versions: 10
Compression:
Stored size: 892 Bytes
Contents
module Restforce # Middleware which asserts that the instance_url is always set class Middleware::InstanceURL < Restforce::Middleware def call(env) # If the instance url isn't set in options, raise a # Restforce::UnauthorizedError to trigger reauthentication. raise Restforce::UnauthorizedError, 'instance url not set' unless @options[:instance_url] # If the url_prefix for the connection doesn't match the instance_url # set in the options, we raise an error which gets caught outside of # middleware, where the url_prefix is then set before retrying the # request. It would be ideal if this could all be handled in # middleware... raise Restforce::InstanceURLError unless connection.url_prefix == instance_url @app.call(env) end def instance_url URI.parse(@options[:instance_url]) end end end
Version data entries
10 entries across 10 versions & 1 rubygems