Module: Axn::Webhooks::Inbound
- Defined in:
- lib/axn/webhooks/inbound.rb,
lib/axn/webhooks/inbound/dsl.rb,
lib/axn/webhooks/inbound/router.rb,
lib/axn/webhooks/inbound/endpoint.rb,
lib/axn/webhooks/inbound/challenge.rb,
lib/axn/webhooks/inbound/build_request.rb,
lib/axn/webhooks/inbound/respond_context.rb,
lib/axn/webhooks/inbound/challenge_required.rb
Overview
Process-global registry of inbound webhook endpoints, populated by
Axn::Webhooks.inbound(:vendor) { ... } and looked up as Inbound[:vendor].
Defined Under Namespace
Classes: BuildRequest, Challenge, ChallengeRequired, DSL, Endpoint, RespondContext, Router
Class Method Summary collapse
- .[](name) ⇒ Object
- .register(name, endpoint) ⇒ Object
- .registered ⇒ Object
-
.replace_declaration(name, endpoints) ⇒ Object
Publish everything one
inbound <name>declaration defines, dropping whatever that same declaration registered last time. - .reset! ⇒ Object
Class Method Details
.[](name) ⇒ Object
22 |
# File 'lib/axn/webhooks/inbound.rb', line 22 def [](name) = @registry.fetch(name.to_sym) { raise KeyError, "no inbound webhook registered for #{name.inspect}" } |
.register(name, endpoint) ⇒ Object
21 |
# File 'lib/axn/webhooks/inbound.rb', line 21 def register(name, endpoint) = @registry[name.to_sym] = endpoint |
.registered ⇒ Object
23 |
# File 'lib/axn/webhooks/inbound.rb', line 23 def registered = @registry.keys |
.replace_declaration(name, endpoints) ⇒ Object
Publish everything one inbound <name> declaration defines, dropping whatever that same
declaration registered last time. Covers every transition — fewer children, more children,
nested becoming plain, plain becoming nested — each of which previously left a route
mounted with its old verifier and handler (Codex review).
Reclaims only the keys this declaration STILL owns. Two declarations can generate the same
endpoint name (inbound :slack with endpoint(:events) vs. a plain inbound :slack_events); last writer wins, which predates nesting — but without the ownership
check, re-declaring the FIRST one would then delete the second one's live route and not
restore it. That deletion is not pre-existing: before this bookkeeping, registration only
ever overwrote (Codex review). A takeover warns rather than raising: the collision is
recoverable, and the endpoint that loses is named so it can be found.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/axn/webhooks/inbound.rb', line 37 def replace_declaration(name, endpoints) key = name.to_sym (@declared[key] || []).each do |registered_name| next unless @owners[registered_name] == key @registry.delete(registered_name) @owners.delete(registered_name) end endpoints.each do |endpoint_name, endpoint| warn_takeover(endpoint_name, key) if @owners.key?(endpoint_name) && @owners[endpoint_name] != key @registry[endpoint_name] = endpoint @owners[endpoint_name] = key end @declared[key] = endpoints.keys end |
.reset! ⇒ Object
56 57 58 59 60 |
# File 'lib/axn/webhooks/inbound.rb', line 56 def reset! @registry.clear @declared.clear @owners.clear end |