Module: Typhoeus::Request::Actions

Included in:
Typhoeus, Typhoeus::Request
Defined in:
lib/typhoeus/request/actions.rb

Overview

Module containing logic about shortcuts to http methods. Like

Typhoeus.get("www.example.com")

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#delete(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a delete request.

Examples:

Make delete request.

Typhoeus.delete("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



72
73
74
# File 'lib/typhoeus/request/actions.rb', line 72

def delete(base_url, options = {})
  Request.new(base_url, options.merge(:method => :delete)).run
end

#get(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a get request.

Examples:

Make get request.

Typhoeus.get("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



21
22
23
# File 'lib/typhoeus/request/actions.rb', line 21

def get(base_url, options = {})
  Request.new(base_url, options.merge(:method => :get)).run
end

#head(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a head request.

Examples:

Make head request.

Typhoeus.head("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



88
89
90
# File 'lib/typhoeus/request/actions.rb', line 88

def head(base_url, options = {})
  Request.new(base_url, options.merge(:method => :head)).run
end

#options(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a options request.

Examples:

Make options request.

Typhoeus.options("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



120
121
122
# File 'lib/typhoeus/request/actions.rb', line 120

def options(base_url, options = {})
  Request.new(base_url, options.merge(:method => :options)).run
end

#patch(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a patch request.

Examples:

Make patch request.

Typhoeus.patch("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



104
105
106
# File 'lib/typhoeus/request/actions.rb', line 104

def patch(base_url, options = {})
  Request.new(base_url, options.merge(:method => :patch)).run
end

#post(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a post request.

Examples:

Make post request.

Typhoeus.post("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Translated into url parameters.

  • :body (Hash)

    Translated into HTTP POST request body.

Returns:

Since:

  • 0.5.0



37
38
39
# File 'lib/typhoeus/request/actions.rb', line 37

def post(base_url, options = {})
  Request.new(base_url, options.merge(:method => :post)).run
end

#put(base_url, options = {}) ⇒ Typhoeus::Request

Note:

See Ethon::Easy::Options for more options.

Make a put request.

Examples:

Make put request.

Typhoeus.put("www.example.com")

Parameters:

  • base_url (String)

    The url to request.

  • options (options) (defaults to: {})

    The options.

Options Hash (options):

  • :params (Hash)

    Params hash which is attached to the base_url.

  • :body (Hash)

    Body hash which becomes a PUT request body.

Returns:

Since:

  • 0.5.0



56
57
58
# File 'lib/typhoeus/request/actions.rb', line 56

def put(base_url, options = {})
  Request.new(base_url, options.merge(:method => :put)).run
end