Module: OpenRouter::HTTP
- Included in:
- Client
- Defined in:
- lib/open_router/http.rb
Instance Method Summary collapse
- #delete(path:) ⇒ Object
- #get(path:) ⇒ Object
- #multipart_post(path:, parameters: nil) ⇒ Object
- #post(path:, parameters:) ⇒ Object
Instance Method Details
#delete(path:) ⇒ Object
30 31 32 33 34 |
# File 'lib/open_router/http.rb', line 30 def delete(path:) conn.delete(uri(path:)) do |req| req.headers = headers end&.body end |
#get(path:) ⇒ Object
5 6 7 8 9 |
# File 'lib/open_router/http.rb', line 5 def get(path:) conn.get(uri(path:)) do |req| req.headers = headers end&.body end |
#multipart_post(path:, parameters: nil) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/open_router/http.rb', line 23 def multipart_post(path:, parameters: nil) conn(multipart: true).post(uri(path:)) do |req| req.headers = headers.merge({ "Content-Type" => "multipart/form-data" }) req.body = multipart_parameters(parameters) end&.body end |
#post(path:, parameters:) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/open_router/http.rb', line 11 def post(path:, parameters:) conn.post(uri(path:)) do |req| if parameters[:stream].respond_to?(:call) req..on_data = to_json_stream(user_proc: parameters[:stream]) parameters[:stream] = true # Necessary to tell OpenRouter to stream. end req.headers = headers req.body = parameters.to_json end&.body end |