Sha256: 23cfddb2c81fb31ec0cf530a4360098f838c3a00786cf3220498ac73349bbb6c

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

module Caliper
  class Rack
    def initialize(app, options = {}, &blk)
      @app = app

      yield self if block_given?
    end

    def call(env)
      if Caliper.config[:enabled] && !env['PATH_INFO'][/^\/assets/]
        env['caliper.tracer'] = Caliper::Tracer.new(env)
      end

      @status, @headers, @response = @app.call(env)

      # check for routing error in rails way
      if @status == 404 && @headers['X-Cascade'] == 'pass'
        Caliper::AppError.create(
          ActionController::RoutingError.new("No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"),
          env
        )
      elsif env['caliper.tracer']
        env['caliper.tracer'].finish
      end

      [@status, @headers, @response]
    rescue Exception => exception
      Caliper::AppError.create(exception, env)
      raise exception
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caliper-0.0.2 lib/caliper/rack.rb
caliper-0.0.1 lib/caliper/rack.rb