Class: Papertrail::HttpClient
- Inherits:
-
Object
- Object
- Papertrail::HttpClient
- Defined in:
- lib/papertrail/http_client.rb
Constant Summary collapse
- ESCAPE_RE =
/[^a-zA-Z0-9 .~_-]/
Instance Method Summary collapse
- #basic_auth(login, pass) ⇒ Object
- #delete(path) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(ssl) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(path, params) ⇒ Object
- #put(path, params) ⇒ Object
- #token_auth(token) ⇒ Object
Constructor Details
#initialize(ssl) ⇒ HttpClient
Returns a new instance of HttpClient.
35 36 37 38 |
# File 'lib/papertrail/http_client.rb', line 35 def initialize(ssl) @ssl = ssl @headers = {} end |
Instance Method Details
#basic_auth(login, pass) ⇒ Object
40 41 42 |
# File 'lib/papertrail/http_client.rb', line 40 def basic_auth(login, pass) @headers['Authorization'] = 'Basic ' + ["#{login}:#{pass}"].pack('m').delete("\r\n") end |
#delete(path) ⇒ Object
60 61 62 |
# File 'lib/papertrail/http_client.rb', line 60 def delete(path) request(:delete, path) end |
#get(path, params = {}) ⇒ Object
48 49 50 |
# File 'lib/papertrail/http_client.rb', line 48 def get(path, params = {}) request(:get, path, params) end |
#post(path, params) ⇒ Object
56 57 58 |
# File 'lib/papertrail/http_client.rb', line 56 def post(path, params) request(:post, path, params) end |
#put(path, params) ⇒ Object
52 53 54 |
# File 'lib/papertrail/http_client.rb', line 52 def put(path, params) request(:put, path, params) end |
#token_auth(token) ⇒ Object
44 45 46 |
# File 'lib/papertrail/http_client.rb', line 44 def token_auth(token) @headers['X-Papertrail-Token'] = token end |