Module: HttpAbstraction
- Extended by:
- RestClientAdapter::API
- Defined in:
- lib/couchrest/middlewares/logger.rb,
lib/couchrest/core/http_abstraction.rb
Overview
Abstraction layet for HTTP communications.
By defining a basic API that CouchRest is relying on, it allows for easy experimentations and implementations of various libraries.
Most of the API is based on the RestClient API that was used in the early version of CouchRest.
Defined Under Namespace
Classes: Conflict, RequestFailed, RequestTimeout, ResourceNotFound, ServerBrokeConnection
Class Method Summary collapse
- .delete(uri, headers = nil) ⇒ Object
- .get(uri, headers = nil) ⇒ Object
- .post(uri, payload, headers = nil) ⇒ Object
- .put(uri, payload, headers = nil) ⇒ Object
Methods included from RestClientAdapter::API
copy, delete, get, post, proxy, proxy=, put
Class Method Details
.delete(uri, headers = nil) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/couchrest/middlewares/logger.rb', line 89 def self.delete(uri, headers=nil) start_query = Time.now log = {:method => :delete, :uri => uri, :headers => headers} response = super(uri, headers=nil) end_query = Time.now log[:duration] = (end_query - start_query) CouchRest::Logger.record(log) response end |
.get(uri, headers = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/couchrest/middlewares/logger.rb', line 59 def self.get(uri, headers=nil) start_query = Time.now log = {:method => :get, :uri => uri, :headers => headers} response = super(uri, headers=nil) end_query = Time.now log[:duration] = (end_query - start_query) CouchRest::Logger.record(log) response end |
.post(uri, payload, headers = nil) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/couchrest/middlewares/logger.rb', line 69 def self.post(uri, payload, headers=nil) start_query = Time.now log = {:method => :post, :uri => uri, :payload => (payload ? (JSON.load(payload) rescue 'parsing error') : nil), :headers => headers} response = super(uri, payload, headers=nil) end_query = Time.now log[:duration] = (end_query - start_query) CouchRest::Logger.record(log) response end |
.put(uri, payload, headers = nil) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/couchrest/middlewares/logger.rb', line 79 def self.put(uri, payload, headers=nil) start_query = Time.now log = {:method => :put, :uri => uri, :payload => (payload ? (JSON.load(payload) rescue 'parsing error') : nil), :headers => headers} response = super(uri, payload, headers=nil) end_query = Time.now log[:duration] = (end_query - start_query) CouchRest::Logger.record(log) response end |