Module: Gemini::HTTP
- Included in:
- Client
- Defined in:
- lib/gemini/http.rb
Instance Method Summary collapse
- #delete(path:) ⇒ Object
- #get(path:) ⇒ Object
- #json_post(path:, parameters:) ⇒ Object
- #multipart_post(path:, parameters: nil) ⇒ Object
Instance Method Details
#delete(path:) ⇒ Object
28 29 30 31 32 |
# File 'lib/gemini/http.rb', line 28 def delete(path:) to_json(conn.delete(uri(path: path)) do |req| req.headers = headers end&.body) end |
#get(path:) ⇒ Object
3 4 5 6 7 |
# File 'lib/gemini/http.rb', line 3 def get(path:) to_json(conn.get(uri(path: path)) do |req| req.headers = headers end&.body) end |
#json_post(path:, parameters:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gemini/http.rb', line 9 def json_post(path:, parameters:) to_json(conn.post(uri(path: adjusted_path(path: path, parameters: parameters))) do |req| if parameters[:stream].is_a?(Proc) req..on_data = to_json_stream(user_proc: parameters[:stream]) end req.headers = headers req.body = parameters.to_json end&.body) end |
#multipart_post(path:, parameters: nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/gemini/http.rb', line 20 def multipart_post(path:, parameters: nil) adjusted_path = adjusted_path(path: path, parameters: parameters) to_json(conn(multipart: true).post(uri(path: adjusted_path)) do |req| req.headers = headers.merge({ "Content-Type" => "multipart/form-data" }) req.body = multipart_parameters(parameters) end&.body) end |