Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.99.x-prod] Fixing ce content type when using binary (#3391) #17

Merged
merged 1 commit into from
Feb 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import org.kie.kogito.addon.quarkus.common.reactive.messaging.MessageDecorator;

import io.quarkus.reactivemessaging.http.runtime.OutgoingHttpMetadata;
import io.smallrye.reactive.messaging.ce.OutgoingCloudEventMetadata;

import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;

/**
* Decorators for Http CloudEvents outgoing messages
Expand All @@ -40,6 +42,12 @@ public class CloudEventHttpOutgoingDecorator implements MessageDecorator {
static final OutgoingHttpMetadata HTTP_RESPONSE_METADATA =
new OutgoingHttpMetadata.Builder().addHeader(HttpHeaders.CONTENT_TYPE, CLOUD_EVENTS_CONTENT_TYPE).build();

/**
* Metadata to include content-type for binary CloudEvents messages
*/
private static final OutgoingHttpMetadata HTTP_BINARY_RESPONSE_METADATA =
new OutgoingHttpMetadata.Builder().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();

/**
* Decorates a given payload with custom metadata needed by Http Outgoing processing
*
Expand All @@ -48,6 +56,6 @@ public class CloudEventHttpOutgoingDecorator implements MessageDecorator {
*/
@Override
public <T> Message<T> decorate(Message<T> message) {
return message.addMetadata(HTTP_RESPONSE_METADATA);
return message.getMetadata(OutgoingCloudEventMetadata.class).isEmpty() ? message.addMetadata(HTTP_RESPONSE_METADATA) : message.addMetadata(HTTP_BINARY_RESPONSE_METADATA);
}
}
Loading