Sha256: 9fae312c8e96a1d041d82f5340232ac9c2140c8f5db1736e16d72490bea67559
Contents?: true
Size: 857 Bytes
Versions: 1
Compression:
Stored size: 857 Bytes
Contents
module Rack class Stackflame ASSET_EXTNAMES = %w[js css png jpg jpeg].freeze def initialize(app, options = {}, &block) @app = app @options = options.dup if block_given? @block = block else @block = -> (env) { not_asset_request?(env) } end end def call(env) result = nil if @block.call(env) stackflame = ::Stackflame.new stackflame.run(@options) do result = @app.call(env) end stackflame.open_flamegraph(request: env['PATH_INFO']) else result = @app.call(env) end result end private def not_asset_request?(env) path = env['PATH_INFO'] return false unless path extname = Pathname.new(path).extname.gsub(/\A\./, '') !ASSET_EXTNAMES.include?(extname) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stackflame-0.2.5 | lib/rack/stackflame.rb |