Top Level Namespace
Defined Under Namespace
Modules: LucidHttp
Instance Method Summary collapse
- #__lucid_http__clean ⇒ Object
- #__lucid_http__setup(url, action: :get, follow: false, form: nil, **opts) ⇒ Object
- #body ⇒ Object
- #content_type ⇒ Object
- #GET(url, **opts) ⇒ Object
- #path ⇒ Object
- #POST(url, **opts) ⇒ Object
- #response ⇒ Object
- #status ⇒ Object
Instance Method Details
#__lucid_http__clean ⇒ Object
25 26 27 28 29 |
# File 'lib/lucid_http.rb', line 25 def __lucid_http__clean instance_variables.grep(/@__lucid_http__/).each do |v| remove_instance_variable(v.to_sym) end end |
#__lucid_http__setup(url, action: :get, follow: false, form: nil, **opts) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/lucid_http.rb', line 31 def __lucid_http__setup(url, action: :get, follow: false, form: nil, **opts) __lucid_http__clean @__lucid_http__client = HTTP.persistent(LucidHttp.target_url) if follow @__lucid_http__client = @__lucid_http__client.follow end @__lucid_http__path = @__lucid_http__client..persistent + url @__lucid_http__res = @__lucid_http__client.send(action.to_sym, url, form: form) end |
#body ⇒ Object
41 42 43 |
# File 'lib/lucid_http.rb', line 41 def body @__lucid_http__body ||= response.body.to_s end |
#content_type ⇒ Object
49 50 51 |
# File 'lib/lucid_http.rb', line 49 def content_type response.content_type.mime_type end |
#GET(url, **opts) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lucid_http.rb', line 57 def GET(url, **opts) __lucid_http__setup(url, **opts) new_body = case status.to_i when 200 body when 500 body.each_line.first else "STATUS: #{status}" end # puts new_body new_body end |
#path ⇒ Object
53 54 55 |
# File 'lib/lucid_http.rb', line 53 def path @__lucid_http__path end |
#POST(url, **opts) ⇒ Object
72 73 74 75 |
# File 'lib/lucid_http.rb', line 72 def POST(url, **opts) __lucid_http__setup(url, action: :post, **opts) body end |
#response ⇒ Object
21 22 23 |
# File 'lib/lucid_http.rb', line 21 def response @__lucid_http__res end |
#status ⇒ Object
45 46 47 |
# File 'lib/lucid_http.rb', line 45 def status @__lucid_http__status = LucidHttp::PrettyStatus.new(response.status) end |