Class: Rack::Indicium::Sentry
- Inherits:
-
Object
- Object
- Rack::Indicium::Sentry
- Defined in:
- lib/rack/indicium/sentry.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #check_for_jwt(env) ⇒ Object
- #client ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(app) ⇒ Sentry
constructor
A new instance of Sentry.
Constructor Details
#initialize(app) ⇒ Sentry
Returns a new instance of Sentry.
6 7 8 9 10 11 12 13 14 |
# File 'lib/rack/indicium/sentry.rb', line 6 def initialize(app) @app = app if defined?(Raven) @sentry_client = Raven else warn "%s: Raven not definied, can't send JWT headers to Sentry." % self.class.to_s end end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 |
# File 'lib/rack/indicium/sentry.rb', line 16 def call(env) check_for_jwt(env) if enabled? @app.call(env) end |
#check_for_jwt(env) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rack/indicium/sentry.rb', line 21 def check_for_jwt(env) context = { "jwt.raw" => env["jwt.raw"], "jwt.header" => env["jwt.header"], "jwt.payload" => env["jwt.payload"], } client.extra_context(context) end |
#client ⇒ Object
30 31 32 |
# File 'lib/rack/indicium/sentry.rb', line 30 def client @sentry_client end |
#enabled? ⇒ Boolean
34 35 36 |
# File 'lib/rack/indicium/sentry.rb', line 34 def enabled? !!@sentry_client end |