Module: WingedCouch::HTTP

Defined in:
lib/winged_couch/http.rb

Overview

Module for sending requests to CouchDB

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hostObject

Returns the value of attribute host


10
11
12
# File 'lib/winged_couch/http.rb', line 10

def host
  @host
end

Class Method Details

.delete(http_path, params = {}) ⇒ Object

Performs DELETE request

Examples:

Usage:

response = WingedCouch::HTTP.delete(path, { key: "value" })

Parameters:

Returns:

  • response


73
74
75
# File 'lib/winged_couch/http.rb', line 73

def delete(http_path, params = {})
  perform(:delete, http_path, { params: params, content_type: :json })
end

.get(http_path, params = {}) ⇒ Object

Performs GET request

Examples:

Usage:

response = WingedCouch::HTTP.get(path, { key: "value" })

Parameters:

Returns:

  • response


31
32
33
# File 'lib/winged_couch/http.rb', line 31

def get(http_path, params = {})
  perform(:get, http_path, { params: params, content_type: :json })
end

.head(http_path) ⇒ Object

Performe HEAD request

Parameters:

Returns:

  • response


83
84
85
# File 'lib/winged_couch/http.rb', line 83

def head(http_path)
  perform(:head, http_path)
end

.pathWingedCouch::HttpPath

Returns default blank http path

(with url to the CouchDB server)

17
18
19
# File 'lib/winged_couch/http.rb', line 17

def path
  HttpPath.new
end

.post(http_path, body = {}) ⇒ Object

Performs POST request

Examples:

Usage:

response = WingedCouch::HTTP.post(path, { key: "value" })

Parameters:

Returns:

  • response


45
46
47
# File 'lib/winged_couch/http.rb', line 45

def post(http_path, body = {})
  perform(:post, http_path, body.to_json, { content_type: :json })
end

.put(http_path, body = {}) ⇒ Object

Performs PUT request

Examples:

Usage:

response = WingedCouch::HTTP.put(path, { key: "value" })

Parameters:

Returns:

  • response


59
60
61
# File 'lib/winged_couch/http.rb', line 59

def put(http_path, body = {})
  perform(:put, http_path, body.to_json, { content_type: :json })
end