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
- #finish ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(ssl) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(path, params) ⇒ Object
- #put(path, params) ⇒ Object
- #start ⇒ Object
- #token_auth(token) ⇒ Object
Constructor Details
permalink #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
permalink #basic_auth(login, pass) ⇒ Object
[View source]
53 54 55 |
# File 'lib/papertrail/http_client.rb', line 53 def basic_auth(login, pass) @headers['Authorization'] = 'Basic ' + ["#{login}:#{pass}"].pack('m').delete("\r\n") end |
permalink #delete(path) ⇒ Object
[View source]
73 74 75 |
# File 'lib/papertrail/http_client.rb', line 73 def delete(path) request(:delete, path) end |
permalink #finish ⇒ Object
[View source]
49 50 51 |
# File 'lib/papertrail/http_client.rb', line 49 def finish https.finish end |
permalink #get(path, params = {}) ⇒ Object
[View source]
61 62 63 |
# File 'lib/papertrail/http_client.rb', line 61 def get(path, params = {}) request(:get, path, params) end |
permalink #post(path, params) ⇒ Object
[View source]
69 70 71 |
# File 'lib/papertrail/http_client.rb', line 69 def post(path, params) request(:post, path, params) end |
permalink #put(path, params) ⇒ Object
[View source]
65 66 67 |
# File 'lib/papertrail/http_client.rb', line 65 def put(path, params) request(:put, path, params) end |
permalink #start ⇒ Object
[View source]
40 41 42 43 44 45 46 47 |
# File 'lib/papertrail/http_client.rb', line 40 def start if block_given? https.start { yield self } else https.start self end end |
permalink #token_auth(token) ⇒ Object
[View source]
57 58 59 |
# File 'lib/papertrail/http_client.rb', line 57 def token_auth(token) @headers['X-Papertrail-Token'] = token end |