module Digdag::Request

Public Instance Methods

delete(path, options={}) click to toggle source
# File lib/digdag_client/request.rb, line 15
def delete(path, options={})
  request(:delete, path, options)
end
get(path, options={}) click to toggle source
# File lib/digdag_client/request.rb, line 3
def get(path, options={})
  request(:get, path, options)
end
post(path, options={}) click to toggle source
# File lib/digdag_client/request.rb, line 7
def post(path, options={})
  request(:post, path, options)
end
put(path, options={}) click to toggle source
# File lib/digdag_client/request.rb, line 11
def put(path, options={})
  request(:put, path, options)
end

Private Instance Methods

request(method, path, options) click to toggle source
# File lib/digdag_client/request.rb, line 20
def request(method, path, options)
  response = connection.send(method) do |request|
    path = "/api/#{path}"
    case method
    when :get, :delete
      request.url(URI.encode(path), options)
    when :post, :put
      if method == :post
        request.headers['Content-Type'] = 'application/json'
      end
      request.path = URI.encode(path)
      request.body = options unless options.empty?
    end
  end

  response.body
end