require "soar_flow/version" require 'rack' require 'securerandom' module SoarFlow class ID attr_reader :app def initialize(app) @app = app end def call(env) request = Rack::Request.new(env) request = generate_or_honor_flow_id(request) request.update_param('flow_identifier', request.params['flow_identifier']) @app.call(env) end def self.generate_flow_id "#{SecureRandom.hex(32)}" end private def generate_or_honor_flow_id(request) if request.params['flow_identifier'].nil? request.params['flow_identifier'] = SoarFlow::ID::generate_flow_id end request end end end