module Ethon::Easy::Http
This module contains logic about making valid HTTP requests.
Public Instance Methods
Set specified options in order to make a HTTP request. Look at {Ethon::Easy::Options Options} to see what you can provide in the options hash.
@example Set options for HTTP request.
easy.http_request("www.google.com", :get, {})
@param [ String ] url The url. @param [ String ] action_name The HTTP action name. @param [ Hash ] options The options hash.
@option options :params [ Hash ] Params
hash which
is attached to the url.
@option options :body [ Hash ] Body hash which
becomes the request body. It is a PUT body for PUT requests and a POST for everything else.
@option options :headers [ Hash ] Request headers.
@return [ void ]
@see Ethon::Easy::Options
# File lib/ethon/easy/http.rb, line 39 def http_request(url, action_name, options = {}) fabricate(url, action_name, options).setup(self) end
Private Instance Methods
Return the corresponding action class.
@example Return the action.
Action.fabricate(:get) Action.fabricate(:smash)
@param [ String ] url The url. @param [ String ] action_name The HTTP action name. @param [ Hash ] options The option hash.
@return [ Easy::Ethon::Actionable ] The request instance.
# File lib/ethon/easy/http.rb, line 56 def fabricate(url, action_name, options) constant_name = action_name.to_s.capitalize if Ethon::Easy::Http.const_defined?(constant_name) Ethon::Easy::Http.const_get(constant_name).new(url, options) else Ethon::Easy::Http::Custom.new(constant_name.upcase, url, options) end end