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

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

Make a DELETE request


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

def self.delete(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :delete, options)
end

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

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


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

def self.get(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :get, options)
end

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

Make a HEAD request


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

def self.head(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :head, options)
end

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

Make a PATCH request


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

def self.patch(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :patch, options)
end

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

Make a POST request


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

def self.post(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :post, options)
end

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

Make a PUT request


33
34
35
36
# File 'motion/http.rb', line 33

def self.put(url, options={}, &block)
  options[:action] = block if block_given?
  HTTP::Query.new(url, :put, options)
end