Class: Squash::Rack
- Inherits:
-
Object
- Object
- Squash::Rack
- Defined in:
- lib/squash/rack.rb,
lib/squash/rack/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
-
#call(env) ⇒ Hash
Rescues any exceptions thrown downstream, notifies Squash, then re-raises them.
-
#filter_for_squash(data, kind) ⇒ Object
abstract
Override this method to implement filtering of sensitive data in the headers, cookies, and rack hashes (see #squash_rack_data).
-
#initialize(app) ⇒ Rack
constructor
Instantiates the middleware.
-
#squash_rack_data(env) ⇒ Hash<Symbol, Object>
The additional information this middleware gives to ‘Squash::Ruby.notify`.
Constructor Details
#initialize(app) ⇒ Rack
Instantiates the middleware.
22 23 24 |
# File 'lib/squash/rack.rb', line 22 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Hash
Rescues any exceptions thrown downstream, notifies Squash, then re-raises them.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/squash/rack.rb', line 31 def call(env) begin result = @app.call(env) rescue ::Exception => ex env['squash.notified'] = ::Squash::Ruby.notify(ex, squash_rack_data(env)) raise ex end result end |
#filter_for_squash(data, kind) ⇒ Object
Override this method to implement filtering of sensitive data in the headers, cookies, and rack hashes (see #squash_rack_data). The method signature is the same as ‘Squash::Ruby#filter_for_squash`, but `kind` can also be `:env` for the Rack environment hash.
49 50 51 |
# File 'lib/squash/rack.rb', line 49 def filter_for_squash(data, kind) data end |
#squash_rack_data(env) ⇒ Hash<Symbol, Object>
Returns The additional information this middleware gives to ‘Squash::Ruby.notify`.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/squash/rack.rb', line 55 def squash_rack_data(env) data = { :headers => filter_for_squash(request_headers(env), :headers), :request_method => env['REQUEST_METHOD'].to_s.upcase, :schema => env['rack.url_scheme'], :host => env['SERVER_NAME'], :port => env['SERVER_PORT'], :path => env['PATH_INFO'], :query => env['QUERY_STRING'], :params => filter_for_squash(env['rack.request.query_hash'], :params), :body => filter_for_squash(env['rack.input'].read, :body), :session => filter_for_squash(env['rack.session'], :session), :cookies => filter_for_squash(env['rack.request.cookie_hash'], :cookies), :"rack.env" => filter_for_squash(env, :rack) } env['rack.input'].rewind data end |