Class: Fadada::HttpClient
- Inherits:
-
Object
- Object
- Fadada::HttpClient
- Defined in:
- lib/fadada/http_client.rb
Class Method Summary collapse
-
.request(method, action, params = {}, digest_params = nil) ⇒ Object
HTTP 请求 digest_params 示例: { _params: { a: 1, b: 2 }, _md5_params: { a: 1, b: 2 }, _extend_params: { a: 1, b: 2 } }.
Class Method Details
.request(method, action, params = {}, digest_params = nil) ⇒ Object
HTTP 请求 digest_params 示例: {
_params: { a: 1, b: 2 },
_md5_params: { a: 1, b: 2 },
_extend_params: { a: 1, b: 2 }
}
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fadada/http_client.rb', line 12 def request(method, action, params = {}, digest_params = nil) _method = method.to_s.downcase _digest_params = digest_params || { _params: params } payload = build_basic_params(_digest_params).merge(params) if _method == 'post' response = HTTParty.post( url(action), body: payload, header: form_header, logger: Fadada::config.logger, log_format: Fadada::config.logger_format ).parsed_response hander_exception(response) else "#{url(action)}?#{URI.encode_www_form(payload)}" end end |