Method: Contentful::Moderator.start

Defined in:
lib/contentful/moderator.rb

.start(config = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contentful/moderator.rb', line 20

def self.start(config = {})
  fail "Moderator not configured" if config.nil? && !block_given?

  if block_given?
    yield(config) if block_given?
  end
  self.config = config

  logger = Logger.new(STDOUT)
  ::Contentful::Webhook::Listener::Server.start do |server_config|
    server_config[:port] = config.port
    server_config[:logger] = logger
    server_config[:endpoints] = [
      {
        endpoint: config.endpoint,
        controller: ::Contentful::Moderator::Controller,
        timeout: 0
      }
    ]
  end.join
end