Class: Quber::HTTP
- Inherits:
-
Object
- Object
- Quber::HTTP
- Defined in:
- lib/quber/http.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- VERBS =
{ get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }
Instance Method Summary collapse
- #base_headers ⇒ Object
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HTTP
Returns a new instance of HTTP.
17 18 19 20 21 22 23 |
# File 'lib/quber/http.rb', line 17 def initialize = {} @defaults = { connection: Net::HTTP::Persistent.new, api_uri: ENV['QUBER_API_URI'] || 'http://localhost:5672/api/v1/', api_token: ENV['QUBER_API_TOKEN'] || '1234567890' }.merge!() end |
Instance Method Details
#base_headers ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/quber/http.rb', line 25 def base_headers { 'X-Auth-Token' => @defaults[:api_token], 'User-Agent' => "Quber/#{Quber::VERSION}", 'Content-Type' => 'application/json' } end |
#delete(path, options = {}) ⇒ Object
45 46 47 |
# File 'lib/quber/http.rb', line 45 def delete(path, = {}) execute(path, :delete, ) end |
#get(path, options = {}) ⇒ Object
33 34 35 |
# File 'lib/quber/http.rb', line 33 def get(path, = {}) execute(path, :get, ) end |
#post(path, options = {}) ⇒ Object
37 38 39 |
# File 'lib/quber/http.rb', line 37 def post(path, = {}) execute(path, :post, ) end |
#put(path, options = {}) ⇒ Object
41 42 43 |
# File 'lib/quber/http.rb', line 41 def put(path, = {}) execute(path, :put, ) end |