Class: ComplyanceSDK::Middleware::RackMiddleware
- Inherits:
-
Object
- Object
- ComplyanceSDK::Middleware::RackMiddleware
- Defined in:
- lib/complyance_sdk/middleware/rack_middleware.rb
Overview
Rack middleware for ComplyanceSDK integration
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
7 8 9 10 |
# File 'lib/complyance_sdk/middleware/rack_middleware.rb', line 7 def initialize(app, = {}) @app = app @options = end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/complyance_sdk/middleware/rack_middleware.rb', line 12 def call(env) # Add ComplyanceSDK context to the request env["complyance_sdk.configured"] = ComplyanceSDK.configured? env["complyance_sdk.environment"] = ComplyanceSDK.configuration&.environment # Add request ID for tracing env["complyance_sdk.request_id"] = generate_request_id status, headers, response = @app.call(env) # Add ComplyanceSDK headers to response if configured if ComplyanceSDK.configured? && @options[:add_headers] headers["X-ComplyanceSDK-Version"] = ComplyanceSDK::VERSION headers["X-ComplyanceSDK-Environment"] = ComplyanceSDK.configuration.environment.to_s end [status, headers, response] end |