Class: HasuraHandler::EventsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/hasura_handler/events_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#protect_against_forgery?

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/hasura_handler/events_controller.rb', line 7

def index
  processor = HasuraHandler::EventProcessor.new(raw_params)

  unless processor.event.valid?
    error_response(processor.event.errors)
    return
  end

  if HasuraHandler.async_events
    processor.process_later
    render json: { queued: true }, status: 202
    return
  end

  processor.process
  if processor.success?
    render json: { success: true }
  else
    error_response(processor.errors)
  end
end