Skip to content

Commit c78c472

Browse files
authored
fix(rest): support application/a2a+json content type
* fix(rest): support application/a2a+json content type
1 parent c2415a4 commit c78c472

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎common/src/main/java/org/a2aproject/sdk/common/MediaType.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ public interface MediaType {
55

66
/** MIME type for JSON content: {@code application/json}. */
77
String APPLICATION_JSON = "application/json";
8+
9+
/** MIME type accepted from HTTP+JSON clients alongside {@code application/json}: {@code application/a2a+json}. */
10+
String APPLICATION_A2A_JSON = "application/a2a+json";
811
}

‎reference/rest/src/main/java/org/a2aproject/sdk/server/rest/quarkus/A2AServerRoutes.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.a2aproject.sdk.server.rest.quarkus;
22

3+
import static org.a2aproject.sdk.common.MediaType.APPLICATION_A2A_JSON;
34
import static org.a2aproject.sdk.server.ServerCallContext.TRANSPORT_KEY;
45
import static org.a2aproject.sdk.spec.A2AMethods.CANCEL_TASK_METHOD;
56
import static org.a2aproject.sdk.spec.A2AMethods.SEND_STREAMING_MESSAGE_METHOD;
@@ -774,13 +775,14 @@ private String extractTenant(RoutingContext rc) {
774775
}
775776

776777
/**
777-
* Check if the request content type is application/json.
778+
* Check if the request content type is application/json or application/a2a+json.
778779
* @param rc the routing context
779-
* @return true if the content type is application/json - false otherwise.
780+
* @return true if the content type is one of those - false otherwise.
780781
*/
781782
private boolean validateContentType(RoutingContext rc) {
782783
String contentType = rc.request().getHeader(CONTENT_TYPE);
783-
if (contentType == null || !contentType.trim().startsWith(APPLICATION_JSON)) {
784+
if (contentType == null || !(contentType.trim().startsWith(APPLICATION_JSON)
785+
|| contentType.trim().startsWith(APPLICATION_A2A_JSON))) {
784786
sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null)));
785787
return false;
786788
}

0 commit comments

Comments
 (0)