Module: BubbleWrap::HTTP

Defined in:
motion/http.rb

Overview

The HTTP module provides a simple interface to make HTTP requests.

TODO: preflight support, easier/better cookie support, better error handling

Defined Under Namespace

Classes: Query, Response

Class Method Summary collapse

Class Method Details

.create_query(url, method, options, block) ⇒ Object



50
51
52
53
# File 'motion/http.rb', line 50

def self.create_query(url, method, options, block)
  options[:action] = block if block
  HTTP::Query.new(url, method, options)
end

.delete(url, options = {}, &block) ⇒ Object

Make a DELETE request



36
37
38
# File 'motion/http.rb', line 36

def self.delete(url, options={}, &block)
  create_query(url, :delete, options, block)
end

.get(url, options = {}, &block) ⇒ Object

Make a GET request and process the response asynchronously via a block.



21
22
23
# File 'motion/http.rb', line 21

def self.get(url, options={}, &block)
  create_query(url, :get, options, block)
end

.head(url, options = {}, &block) ⇒ Object

Make a HEAD request



41
42
43
# File 'motion/http.rb', line 41

def self.head(url, options={}, &block)
  create_query(url, :head, options, block)
end

.patch(url, options = {}, &block) ⇒ Object

Make a PATCH request



46
47
48
# File 'motion/http.rb', line 46

def self.patch(url, options={}, &block)
  create_query(url, :patch, options, block)
end

.post(url, options = {}, &block) ⇒ Object

Make a POST request



26
27
28
# File 'motion/http.rb', line 26

def self.post(url, options={}, &block)
  create_query(url, :post, options, block)
end

.put(url, options = {}, &block) ⇒ Object

Make a PUT request



31
32
33
# File 'motion/http.rb', line 31

def self.put(url, options={}, &block)
  create_query(url, :put, options, block)
end