Class: A2A::Server::WellKnown
- Inherits:
-
Object
- Object
- A2A::Server::WellKnown
- Defined in:
- lib/a2a/server/well_known.rb
Overview
Rack middleware that serves the agent card at the well-known discovery path. All other requests pass through untouched.
Constant Summary collapse
- PATH =
"/.well-known/agent-card.json"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ WellKnown
constructor
A new instance of WellKnown.
Constructor Details
#initialize(app) ⇒ WellKnown
Returns a new instance of WellKnown.
14 15 16 |
# File 'lib/a2a/server/well_known.rb', line 14 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/a2a/server/well_known.rb', line 18 def call(env) return @app.call(env) unless env["PATH_INFO"] == PATH card = env["a2a.agent_card"] || {} body = card.is_a?(Hash) ? card : card.to_h [200, { "content-type" => "application/json" }, [JSON.generate(body)]] end |