Sha256: fff2ca967e8581602ea233baac37cd689a8e0e3909a56bb8b83fc056d9508ef4

Contents?: true

Size: 1.12 KB

Versions: 39

Compression:

Stored size: 1.12 KB

Contents

# typed: ignore

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

module Sqreen
  module Dependency
    module Rack
      module_function

      def find_handler(&block)
        Sqreen::Graft::Hook.add('Rack::Server#server') do
          after do |call|
            callback = call.callback
            server = call.returned

            block.call(server)
            callback.disable # do this once, :server is a lazy init accessor
          end
        end
        Sqreen::Graft::Hook['Rack::Server#server'].install
      end

      def on_run(handler, &block)
        Sqreen.log.debug "[#{Process.pid}] #{handler.inspect}"
        hookpoint_name = "#{handler.name}.run"

        Sqreen::Graft::Hook.add(hookpoint_name) do
          before { block.call(handler) }
        end
        Sqreen::Graft::Hook[hookpoint_name].install
      end

      def rackup?
        return false if Sqreen::Dependency::Rails.server?

        Sqreen::Dependency.const_exist?('Rack::Server') && ObjectSpace.each_object(::Rack::Server).count > 0
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/dependency/rack.rb
sqreen-1.25.0 lib/sqreen/dependency/rack.rb
sqreen-1.24.3 lib/sqreen/dependency/rack.rb
sqreen-1.24.2 lib/sqreen/dependency/rack.rb
sqreen-1.24.1 lib/sqreen/dependency/rack.rb
sqreen-1.24.0 lib/sqreen/dependency/rack.rb
sqreen-1.23.2 lib/sqreen/dependency/rack.rb
sqreen-1.23.1 lib/sqreen/dependency/rack.rb
sqreen-1.23.0 lib/sqreen/dependency/rack.rb
sqreen-1.22.1 lib/sqreen/dependency/rack.rb
sqreen-1.22.0-java lib/sqreen/dependency/rack.rb
sqreen-1.22.0 lib/sqreen/dependency/rack.rb
sqreen-1.21.1-java lib/sqreen/dependency/rack.rb
sqreen-1.21.1 lib/sqreen/dependency/rack.rb
sqreen-1.21.0-java lib/sqreen/dependency/rack.rb
sqreen-1.21.0 lib/sqreen/dependency/rack.rb
sqreen-1.20.4-java lib/sqreen/dependency/rack.rb
sqreen-1.20.4 lib/sqreen/dependency/rack.rb
sqreen-1.21.0.beta3-java lib/sqreen/dependency/rack.rb
sqreen-1.21.0.beta3 lib/sqreen/dependency/rack.rb