Class: Operaton::Bpm::Client::Interceptor::Impl::RequestInterceptorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/operaton/bpm/client/interceptor/impl/request_interceptor_handler.rb

Overview

Mirrors org.operaton.bpm.client.interceptor.impl.RequestInterceptorHandler. Applied to every outgoing HTTP request by the RequestExecutor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interceptors) ⇒ RequestInterceptorHandler

Returns a new instance of RequestInterceptorHandler.



16
17
18
# File 'lib/operaton/bpm/client/interceptor/impl/request_interceptor_handler.rb', line 16

def initialize(interceptors)
  @interceptors = interceptors
end

Instance Attribute Details

#interceptorsObject (readonly)

Returns the value of attribute interceptors.



14
15
16
# File 'lib/operaton/bpm/client/interceptor/impl/request_interceptor_handler.rb', line 14

def interceptors
  @interceptors
end

Instance Method Details

#process(http_request) ⇒ Object

http_request is a Net::HTTPRequest; interceptor headers are added to it.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/operaton/bpm/client/interceptor/impl/request_interceptor_handler.rb', line 21

def process(http_request)
  intercepted_request = ClientRequestContextImpl.new

  interceptors.each do |request_interceptor|
    if request_interceptor.respond_to?(:intercept)
      request_interceptor.intercept(intercepted_request)
    else
      request_interceptor.call(intercepted_request)
    end
  rescue StandardError => e
    Client::Impl::ExternalTaskClientLogger.engine_client_logger.request_interceptor_exception(e)
  end

  intercepted_request.headers.each do |name, value|
    http_request[name] = value
  end
end