Module: Booru::Request
- Included in:
- Client
- Defined in:
- lib/booru/request.rb
Constant Summary collapse
- HEADERS =
{ 'User-Agent' => 'Mozilla/5.0', }
Instance Method Summary collapse
- #get(path, options = {}) ⇒ Object
- #post(path, options = {}) ⇒ Object
-
#request(method, path, options) ⇒ Object
Perform an HTTP request.
Instance Method Details
#get(path, options = {}) ⇒ Object
9 10 11 |
# File 'lib/booru/request.rb', line 9 def get(path, ={}) request(:get, path, HEADERS.merge()) end |
#post(path, options = {}) ⇒ Object
13 14 15 |
# File 'lib/booru/request.rb', line 13 def post(path, = {}) request(:post, path, HEADERS.merge()) end |
#request(method, path, options) ⇒ Object
Perform an HTTP request
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/booru/request.rb', line 18 def request(method, path, ) case method when :get response = RestClient.get("#{@host}#{path}", ) when :post response = RestClient.post("#{@host}#{path}", ) end raise_errors(response) response end |