Sha256: 21719dfc6aa53c73696e8adfec7bcbe48a26b64fe8e56c83d89039af92cde1ac
Contents?: true
Size: 1.36 KB
Versions: 4
Compression:
Stored size: 1.36 KB
Contents
module ProjectlockerErrata # Middleware for Rack applications. Any errors raised by the upstream # application will be delivered to ProjectlockerErrata and re-raised. # # Synopsis: # # require 'rack' # require 'projectlocker_errata' # # ProjectlockerErrata.configure do |config| # config.api_key = 'my_api_key' # end # # app = Rack::Builder.app do # run lambda { |env| raise "Rack down" } # end # # use ProjectlockerErrata::Rack # run app # # Use a standard ProjectlockerErrata.configure call to configure your api key. class Rack def initialize(app) @app = app end def ignored_user_agent?(env) true if ProjectlockerErrata. configuration. ignore_user_agent. flatten. any? { |ua| ua === env['HTTP_USER_AGENT'] } end def notify_projectlocker_errata(exception,env) ProjectlockerErrata.notify_or_ignore(exception,:rack_env => env) unless ignored_user_agent?(env) end def call(env) begin response = @app.call(env) rescue Exception => raised env['projectlocker_errata.error_id'] = notify_projectlocker_errata(raised,env) raise end if env['rack.exception'] env['projectlocker_errata.error_id'] = notify_projectlocker_errata(env['rack.exception'],env) end response end end end
Version data entries
4 entries across 4 versions & 1 rubygems