Skip to content

Commit 35731c7

Browse files
committed
Remove unneeded refactoring
1 parent b36f175 commit 35731c7

File tree

2 files changed

+25
-37
lines changed

2 files changed

+25
-37
lines changed

src/a2a/server/apps/jsonrpc/jsonrpc_app.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -434,39 +434,6 @@ async def _handle_get_authenticated_extended_agent_card(
434434
status_code=404,
435435
)
436436

437-
def _get_route_definitions(
438-
self,
439-
agent_card_url: str,
440-
rpc_url: str,
441-
extended_agent_card_url: str,
442-
) -> list[dict[str, Any]]:
443-
"""Generates a list of route definitions for the application."""
444-
routes = [
445-
{
446-
'path': rpc_url,
447-
'endpoint': self._handle_requests,
448-
'methods': ['POST'],
449-
'name': 'a2a_handler',
450-
},
451-
{
452-
'path': agent_card_url,
453-
'endpoint': self._handle_get_agent_card,
454-
'methods': ['GET'],
455-
'name': 'agent_card',
456-
},
457-
]
458-
459-
if self.agent_card.supportsAuthenticatedExtendedCard:
460-
routes.append(
461-
{
462-
'path': extended_agent_card_url,
463-
'endpoint': self._handle_get_authenticated_extended_agent_card,
464-
'methods': ['GET'],
465-
'name': 'authenticated_extended_agent_card',
466-
}
467-
)
468-
return routes
469-
470437
@abstractmethod
471438
def build(
472439
self,

src/a2a/server/apps/jsonrpc/starlette_app.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,31 @@ def routes(
4242
Returns:
4343
A list of Starlette Route objects.
4444
"""
45-
route_definitions = self._get_route_definitions(
46-
agent_card_url, rpc_url, extended_agent_card_url
47-
)
48-
return [Route(**route_def) for route_def in route_definitions]
45+
app_routes = [
46+
Route(
47+
rpc_url,
48+
self._handle_requests,
49+
methods=['POST'],
50+
name='a2a_handler',
51+
),
52+
Route(
53+
agent_card_url,
54+
self._handle_get_agent_card,
55+
methods=['GET'],
56+
name='agent_card',
57+
),
58+
]
59+
60+
if self.agent_card.supportsAuthenticatedExtendedCard:
61+
app_routes.append(
62+
Route(
63+
extended_agent_card_url,
64+
self._handle_get_authenticated_extended_agent_card,
65+
methods=['GET'],
66+
name='authenticated_extended_agent_card',
67+
)
68+
)
69+
return app_routes
4970

5071
def add_routes_to_app(
5172
self,

0 commit comments

Comments
 (0)