Skip to content

Commit 9125136

Browse files
authored
chore: update Quarkus example (#466)
* Server accepts both: binary and structured encoded events. * Emitter contains comment describing how to switch between binary and structured encoding for emitted events. Signed-off-by: Matej Vasek <mvasek@redhat.com>
1 parent f35e6e6 commit 9125136

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/restful-ws-quarkus/src/main/java/io/cloudevents/examples/quarkus/client/UserClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
@RegisterRestClient
1313
public interface UserClient {
1414

15+
// This will emit binary encoded events.
16+
// To use structured JSON encoding use @Produces(JsonFormat.CONTENT_TYPE).
1517
@POST
1618
@Produces(MediaType.APPLICATION_JSON)
1719
void emit(CloudEvent event);

examples/restful-ws-quarkus/src/main/java/io/cloudevents/examples/quarkus/resources/UserResource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import io.cloudevents.CloudEvent;
55
import io.cloudevents.examples.quarkus.model.User;
6+
import io.cloudevents.jackson.JsonFormat;
67
import io.cloudevents.jackson.PojoCloudEventDataMapper;
78
import org.slf4j.Logger;
89
import org.slf4j.LoggerFactory;
@@ -17,8 +18,8 @@
1718
import java.util.Map;
1819

1920
@Path("/users")
20-
@Consumes(MediaType.APPLICATION_JSON)
21-
@Produces(MediaType.APPLICATION_JSON)
21+
@Consumes({MediaType.APPLICATION_JSON, JsonFormat.CONTENT_TYPE})
22+
@Produces({MediaType.APPLICATION_JSON})
2223
public class UserResource {
2324

2425
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);

0 commit comments

Comments
 (0)