Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/a2a/server/apps/jsonrpc/fastapi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

from typing import Any

from fastapi import FastAPI, Request, Response
from fastapi import FastAPI

from a2a.server.apps.jsonrpc.jsonrpc_app import (
CallContextBuilder,
JSONRPCApplication,
)
from a2a.server.request_handlers.jsonrpc_handler import RequestHandler
from a2a.types import AgentCard
from a2a.utils.constants import (
AGENT_CARD_WELL_KNOWN_PATH,
DEFAULT_RPC_URL,
EXTENDED_AGENT_CARD_PATH,
)


logger = logging.getLogger(__name__)


class A2AFastAPIApplication(JSONRPCApplication):

Check notice on line 23 in src/a2a/server/apps/jsonrpc/fastapi_app.py

View workflow job for this annotation

GitHub Actions / Lint Code Base

Copy/pasted code

see src/a2a/server/apps/jsonrpc/starlette_app.py (8-24)
"""A FastAPI application implementing the A2A protocol server endpoints.

Handles incoming JSON-RPC requests, routes them to the appropriate
Expand Down Expand Up @@ -69,22 +69,13 @@
rpc_url: The URL for the A2A JSON-RPC endpoint.
extended_agent_card_url: The URL for the authenticated extended agent card endpoint.
"""

@app.post(rpc_url)
async def handle_a2a_request(request: Request) -> Response:
return await self._handle_requests(request)

@app.get(agent_card_url)
async def get_agent_card(request: Request) -> Response:
return await self._handle_get_agent_card(request)
app.post(rpc_url)(self._handle_requests)
app.get(agent_card_url)(self._handle_get_agent_card)

if self.agent_card.supportsAuthenticatedExtendedCard:

@app.get(extended_agent_card_url)
async def get_extended_agent_card(request: Request) -> Response:
return await self._handle_get_authenticated_extended_agent_card(
request
)
app.get(extended_agent_card_url)(
self._handle_get_authenticated_extended_agent_card
)

def build(
self,
Expand Down
Loading