Class: Served::Backends::HTTP
- Inherits:
-
Base
- Object
- Base
- Served::Backends::HTTP
show all
- Defined in:
- lib/served/backends/http.rb
Overview
HTTP Backend uses HTTP client library.
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #serialize_response
Instance Method Details
#delete(endpoint, id, params = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/served/backends/http.rb', line 41
def delete(endpoint, id, params = {})
response = ::HTTP
.timeout(global: timeout)
.()
.delete(template.expand(query: params,
resource: endpoint,
id: id).to_s)
serialize_response(response)
rescue ::HTTP::ConnectionError
raise Served::HTTPClient::ConnectionFailed.new(resource)
end
|
#get(endpoint, id, params = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/served/backends/http.rb', line 6
def get(endpoint, id, params = {})
response = ::HTTP
.timeout(global: timeout)
.()
.get(template.expand(id: id, query: params, resource: endpoint).to_s)
serialize_response(response)
rescue ::HTTP::ConnectionError
raise Served::HTTPClient::ConnectionFailed.new(resource)
end
|
#post(endpoint, body, params = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/served/backends/http.rb', line 29
def post(endpoint, body, params = {})
response = ::HTTP
.timeout(global: timeout)
.()
.post(template.expand(query: params,
resource: endpoint).to_s,
body: body)
serialize_response(response)
rescue ::HTTP::ConnectionError
raise Served::HTTPClient::ConnectionFailed.new(resource)
end
|
#put(endpoint, id, body, params = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/served/backends/http.rb', line 16
def put(endpoint, id, body, params = {})
response = ::HTTP
.timeout(global: timeout)
.()
.put(template.expand(id: id,
query: params,
resource: endpoint).to_s,
body: body)
serialize_response(response)
rescue ::HTTP::ConnectionError
raise Served::HTTPClient::ConnectionFailed.new(resource)
end
|