Class: Cloudflare::KV::RESTWrapper
- Inherits:
-
Async::REST::Wrapper::Generic
- Object
- Async::REST::Wrapper::Generic
- Cloudflare::KV::RESTWrapper
show all
- Defined in:
- lib/cloudflare/kv/rest_wrapper.rb
Defined Under Namespace
Classes: JsonParser, OctetParser
Constant Summary
collapse
- APPLICATION_OCTET_STREAM =
'application/octet-stream'
- APPLICATION_JSON =
'application/json'
"#{APPLICATION_JSON}, #{APPLICATION_OCTET_STREAM}"
Instance Method Summary
collapse
Instance Method Details
#parser_for(response) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/cloudflare/kv/rest_wrapper.rb', line 21
def parser_for(response)
if response.['content-type'].start_with?(APPLICATION_OCTET_STREAM)
OctetParser
elsif response.['content-type'].start_with?(APPLICATION_JSON)
JsonParser
else
Async::REST::Wrapper::Generic::Unsupported
end
end
|
#prepare_request(payload, headers) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/cloudflare/kv/rest_wrapper.rb', line 12
def prepare_request(payload, )
['accept'] ||= ACCEPT_HEADER
if payload
['content-type'] = APPLICATION_OCTET_STREAM
::Protocol::HTTP::Body::Buffered.new([payload.to_s])
end
end
|