Class: Couch::Server
- Inherits:
-
Object
- Object
- Couch::Server
- Defined in:
- lib/fluent/plugin/out_couch.rb
Instance Method Summary collapse
- #delete(uri) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize(host, port, options = nil) ⇒ Server
constructor
A new instance of Server.
- #post(uri, json) ⇒ Object
- #put(uri, json) ⇒ Object
- #request(req) ⇒ Object
Constructor Details
#initialize(host, port, options = nil) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 |
# File 'lib/fluent/plugin/out_couch.rb', line 5 def initialize(host, port, = nil) @host = host @port = port = end |
Instance Method Details
#delete(uri) ⇒ Object
11 12 13 |
# File 'lib/fluent/plugin/out_couch.rb', line 11 def delete(uri) request(Net::HTTP::Delete.new(uri)) end |
#get(uri) ⇒ Object
15 16 17 |
# File 'lib/fluent/plugin/out_couch.rb', line 15 def get(uri) request(Net::HTTP::Get.new(uri)) end |
#post(uri, json) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_couch.rb', line 26 def post(uri, json) req = Net::HTTP::Post.new(uri) req["content-type"] = "application/json" req.body = json request(req) end |
#put(uri, json) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/fluent/plugin/out_couch.rb', line 19 def put(uri, json) req = Net::HTTP::Put.new(uri) req["content-type"] = "application/json" req.body = json request(req) end |
#request(req) ⇒ Object
33 34 35 36 |
# File 'lib/fluent/plugin/out_couch.rb', line 33 def request(req) res = Net::HTTP.start(@host, @port) { |http|http.request(req) } res end |