Class: Scrubber::Middleware
- Inherits:
-
Object
- Object
- Scrubber::Middleware
- Defined in:
- lib/scrubber/middleware.rb,
sig/scrubber_rb.rbs
Overview
Rack middleware. Non-destructive: publishes redacted copies at env.
Constant Summary collapse
- QUERY_STRING =
"QUERY_STRING"- ENV_QUERY =
"scrubber.query_string"- ENV_PARAMS =
"scrubber.params"- ENV_INSTANCE =
"scrubber.instance"
Instance Attribute Summary collapse
-
#scrubber ⇒ Instance
readonly
Returns the value of attribute scrubber.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, scrubber: nil, scrub_exceptions: true, **options) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, scrubber: nil, scrub_exceptions: true, **options) ⇒ Middleware
Returns a new instance of Middleware.
38 39 40 41 42 |
# File 'lib/scrubber/middleware.rb', line 38 def initialize(app, scrubber: nil, scrub_exceptions: true, **) @app = app @scrubber = scrubber || Scrubber.new(**) @scrub_exceptions = scrub_exceptions end |
Instance Attribute Details
#scrubber ⇒ Instance (readonly)
Returns the value of attribute scrubber.
32 33 34 |
# File 'lib/scrubber/middleware.rb', line 32 def scrubber @scrubber end |
Instance Method Details
#call(env) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/scrubber/middleware.rb', line 44 def call(env) annotate(env) @app.call(env) rescue StandardError => e raise unless @scrub_exceptions raise redacted(e) end |