Skip to content

Commit 804a1f4

Browse files
authored
Merge branch 'main' into make-fastapi-package-optional
2 parents 14d2db5 + cb08973 commit 804a1f4

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
from typing import TYPE_CHECKING, Any
44

5-
65
if TYPE_CHECKING:
7-
from fastapi import FastAPI, Request, Response
6+
from fastapi import FastAPI
87

98
_package_fastapi_installed = True
109
else:
1110
try:
12-
from fastapi import FastAPI, Request, Response
11+
from fastapi import FastAPI
1312

1413
_package_fastapi_installed = True
1514
except ImportError:
1615
FastAPI = Any
17-
Request = Any
18-
Response = Any
1916

2017
_package_fastapi_installed = False
2118

@@ -90,22 +87,13 @@ def add_routes_to_app(
9087
rpc_url: The URL for the A2A JSON-RPC endpoint.
9188
extended_agent_card_url: The URL for the authenticated extended agent card endpoint.
9289
"""
93-
94-
@app.post(rpc_url)
95-
async def handle_a2a_request(request: Request) -> Response:
96-
return await self._handle_requests(request)
97-
98-
@app.get(agent_card_url)
99-
async def get_agent_card(request: Request) -> Response:
100-
return await self._handle_get_agent_card(request)
90+
app.post(rpc_url)(self._handle_requests)
91+
app.get(agent_card_url)(self._handle_get_agent_card)
10192

10293
if self.agent_card.supportsAuthenticatedExtendedCard:
103-
104-
@app.get(extended_agent_card_url)
105-
async def get_extended_agent_card(request: Request) -> Response:
106-
return await self._handle_get_authenticated_extended_agent_card(
107-
request
108-
)
94+
app.get(extended_agent_card_url)(
95+
self._handle_get_authenticated_extended_agent_card
96+
)
10997

11098
def build(
11199
self,

0 commit comments

Comments
 (0)