Method: Celery::API#call

Defined in:
lib/celery.rb

#call(method, path, opts = {}, &block) ⇒ Object

Make a request to the Celery API

Parameters:

  • verb (Symbol)

    the HTTP request method

  • path (String)

    the HTTP URL path of the request

  • opts (Hash) (defaults to: {})

    the options to make the request with



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/celery.rb', line 37

def call(method, path, opts={}, &block) # :nodoc:
  # Ensure the body is JSON
  opts[:body] = JSON.generate(opts[:body]) if opts[:body] 
  # Set the headers
  opts[:headers] ||= {}
  opts[:headers].merge!(headers)
  # Set the path
  opts[:path] = "#{@path}/#{path}"
  # Set the access token
  # TODO: Remove and use HTTP Basic Authorization
  opts[:query] ||= {}
  opts[:query].merge!(access_token: @token)
  # Make the request
  req = @session.send(method, opts)
  # Handle the response
  handle_response(req)
end