Class: Mailgun::Tracking::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/mailgun/tracking/middleware.rb

Overview

Rack-based middleware to handle event notifications.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Initializes a new Middleware object.


8
9
10
# File 'lib/mailgun/tracking/middleware.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array(Numeric,Hash,Array)

Responds to Rack requests.


17
18
19
20
21
22
23
24
25
26
# File 'lib/mailgun/tracking/middleware.rb', line 17

def call(env)
  @env = env

  if mailgun_tracking_request?
    Mailgun::Tracking.notifier.broadcast(request.params.fetch('event'), request.params)
    null_response
  else
    @app.call(env)
  end
end