Module: WxExt::Helper

Extended by:
Helper
Included in:
Helper
Defined in:
lib/wx_ext/helper.rb

Overview

WxExt Helper like get and post short method.

Author:

  • FuShengYang

Instance Method Summary collapse

Instance Method Details

#http_get(url, headers = {}) ⇒ Hash

Http get helper of this gem, always return a hash.

Parameters:

  • url (Enumerable<String>)
  • headers (Hash) (defaults to: {})

Returns:

  • (Hash)

    A json parse hash.



16
17
18
19
# File 'lib/wx_ext/helper.rb', line 16

def http_get(url, headers = {})
  res = RestClient.get url, headers
  JSON.parse res
end

#http_post(url, params, headers = {}) ⇒ Hash

Http post helper of this gem, always return a hash.

Parameters:

  • url (Enumerable<String>)
  • params (Hash)
  • headers (Hash) (defaults to: {})

Returns:

  • (Hash)

    A json parse hash.



27
28
29
30
# File 'lib/wx_ext/helper.rb', line 27

def http_post(url, params, headers = {})
  res = RestClient.post url, params, headers
  JSON.parse res
end