Class: TxghQueue::Webhooks::Gitlab::RequestHandler

Inherits:
TxghServer::Webhooks::Gitlab::RequestHandler
  • Object
show all
Defined in:
lib/txgh-queue/webhooks/gitlab/request_handler.rb

Instance Method Summary collapse

Instance Method Details

#handle_requestObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/txgh-queue/webhooks/gitlab/request_handler.rb', line 7

def handle_request
  handle_safely do
    case gitlab_event
      when 'Push Hook'
        txgh_event = delete_event? ? 'gitlab.delete' : 'gitlab.push'

        result = ::TxghQueue::Config.backend
          .producer_for(txgh_event, logger)
          .enqueue(attributes.to_h.merge(txgh_event: txgh_event))

        respond_with(202, result.to_json)
      else
        respond_with_error(400, "Event '#{gitlab_event}' cannot be enqueued")
    end
  end
end