Sha256: bba0eca2550897030f2aacc11bb6b97fede42fd74fe8555409d8e9509b434d2c

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

module Marlowe
  class Railtie < Rails::Railtie # :nodoc:
    initializer "marlowe.configure_rails_initialization" do
      config = app.config

      opts = {
        header: config.try(:marlowe_header) || config.try(:marlowe_correlation_header),
        handler: config.try(:marlowe_request_id_handler),
        return: config.try(:marlowe_return_request_id),
        action_dispatch: config.try(:marlowe_replace_action_dispatch_request_id)
      }.compact

      if opts[:action_dispatch]
        app.middleware.insert_before ActionDispatch::RequestId,
          Marlowe::Middleware, opts
        app.middleware.delete ActionDispatch::RequestId
      else
        app.middleware.insert_before Rails::Rack::Logger, Marlowe::Middleware,
          opts
      end
    end

    def app #:nodoc:
      Rails.application
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marlowe-2.1 lib/marlowe/rails.rb