module Knodes::Request
Public Instance Methods
delete(path, options={}, raw=false, unformatted=false, debug=false)
click to toggle source
Perform an HTTP DELETE request
# File lib/knodes/request.rb, line 19 def delete(path, options={}, raw=false, unformatted=false, debug=false) request(:delete, path, options, raw, unformatted, debug) end
get(path, options={}, raw=false, unformatted=false, debug=false)
click to toggle source
Perform an HTTP GET request
# File lib/knodes/request.rb, line 4 def get(path, options={}, raw=false, unformatted=false, debug=false) request(:get, path, options, raw, unformatted, debug) end
post(path, options={}, raw=false, unformatted=false, debug=false)
click to toggle source
Perform an HTTP POST request
# File lib/knodes/request.rb, line 9 def post(path, options={}, raw=false, unformatted=false, debug=false) request(:post, path, options, raw, unformatted, debug) end
put(path, options={}, raw=false, unformatted=false, debug=false)
click to toggle source
Perform an HTTP PUT request
# File lib/knodes/request.rb, line 14 def put(path, options={}, raw=false, unformatted=false, debug=false) request(:put, path, options, raw, unformatted, debug) end
Private Instance Methods
formatted_path(path)
click to toggle source
# File lib/knodes/request.rb, line 42 def formatted_path(path) [path, format].compact.join('.') end
request(method, path, options, raw=false, unformatted=false, debug=false)
click to toggle source
Perform an HTTP request
# File lib/knodes/request.rb, line 26 def request(method, path, options, raw=false, unformatted=false, debug=false) response = connection(raw).send(method) do |request| path = formatted_path(path) unless unformatted case method when :get, :delete request.url(path, options) when :post, :put request.path = path request.body = options unless options.empty? end puts response.inspect if debug end raw ? response : response.body end