6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/tiler/ingest_controller.rb', line 6
def create
body = request.body.read
parsed = body.present? ? JSON.parse(body) : {}
records = parsed.is_a?(Array) ? parsed : [ parsed ]
service = DataIngestionService.new(@source, records, via: "webhook")
service.call
render json: { accepted: service.accepted, errors: service.errors },
status: service.success? ? :created : :unprocessable_entity
rescue JSON::ParserError
render json: { error: "Invalid JSON" }, status: :bad_request
end
|