Class: Insika::Server::A2A::Http
- Inherits:
-
Object
- Object
- Insika::Server::A2A::Http
- Defined in:
- lib/insika/server/a2a/http.rb
Overview
Production HTTP adapter: implements the duck-type
post_json(url, body) -> Hash over async-http (runs on the turn's reactor).
BOUNDARY — the lib require lives here, never in lib/insika.rb/wiring-load.
The Client (the logic) is tested with a fake; this adapter, with a light test.
Constant Summary collapse
- HEADERS =
[["content-type", "application/json"], ["accept", "application/json"]].freeze
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(internet: nil) ⇒ Http
constructor
A new instance of Http.
-
#post_json(url, body) ⇒ Object
POST JSON -> Hash (parsed JSON-RPC, string keys).
Constructor Details
#initialize(internet: nil) ⇒ Http
Returns a new instance of Http.
15 16 17 |
# File 'lib/insika/server/a2a/http.rb', line 15 def initialize(internet: nil) @internet = internet # lazy: Async::HTTP::Internet.new end |
Instance Method Details
#close ⇒ Object
25 26 27 28 29 |
# File 'lib/insika/server/a2a/http.rb', line 25 def close @internet&.close rescue StandardError nil # best-effort end |
#post_json(url, body) ⇒ Object
POST JSON -> Hash (parsed JSON-RPC, string keys).
20 21 22 23 |
# File 'lib/insika/server/a2a/http.rb', line 20 def post_json(url, body) response = internet.post(url, HEADERS, JSON.generate(body)) JSON.parse(response.read.to_s) end |