Class: A2A::PushNotification::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/push_notification/receiver.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, path: "/a2a/webhook", scheme: "Bearer", credentials: nil, &handler) ⇒ Receiver

Returns a new instance of Receiver.



9
10
11
12
13
14
15
# File 'lib/a2a/push_notification/receiver.rb', line 9

def initialize(app, path: "/a2a/webhook", scheme: "Bearer", credentials: nil, &handler)
  @app = app
  @path = path
  @scheme = scheme
  @credentials = credentials
  @handler = handler
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/a2a/push_notification/receiver.rb', line 17

def call(env)
  request = Rack::Request.new(env)
  return @app.call(env) unless request.post? && request.path == @path
  return unauthorized unless authorized?(request)

  handle_event(request)
end