Class: Net::HTTP
- Inherits:
-
Object
- Object
- Net::HTTP
- Defined in:
- lib/net/http.rb
Overview
TODO Implement HTTP with jQuery for use in Glimmer DSL for Opal TODO Re-Implement in Fetch in the future Note: ignore Protocol superclass for now
Class Method Summary collapse
Class Method Details
.get(uri, path_and_params) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/net/http.rb', line 39 def get(uri, path_and_params) uri = File.join(uri, path_and_params) uri = "#{`window.location.protocol`}//#{uri}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code result = nil ::HTTP.get(uri, {async: false, dataType: 'text'}) do |response| result = response.body if response.ok? end result end |
.post_form(uri, params) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/net/http.rb', line 30 def post_form(uri, params) uri = "#{`window.location.protocol`}//#{File.join(uri)}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code result = nil ::HTTP.post(uri, {async: false, dataType: 'text', data: params}) do |response| result = response.body if response.ok? end result end |