Generic HTTP Protocol Binding

Javadocs

This module is designed to be usable with various HTTP APIs.

There are also more specialized HTTP bindings:

Since this module is generic it doesn’t offer optimal performance for all HTTP implementations. For better performance consider implementing MessageReader and MessageWriter that are tailored for specific HTTP implementation. As a reference you can take aforementioned existing bindings.

For Maven based projects, use the following to configure the CloudEvents Generic HTTP Transport:

<dependency>
    <groupId>io.cloudevents</groupId>
    <artifactId>cloudevents-http-basic</artifactId>
    <version>4.0.1</version>
</dependency>

Sending and Receiving CloudEvents

To send and receive CloudEvents we use MessageWriter and MessageReader, respectively. This module offers factory methods for creation of those in HttpMessageFactory.

public class HttpMessageFactory {
    public static MessageReader createReader(Consumer<BiConsumer<String,String>> forEachHeader, byte[] body);
    public static MessageReader createReader(Map<String,String> headers, byte[] body);
    public static MessageReader createReaderFromMultimap(Map<String,List<String>> headers, byte[] body);
    public static MessageWriter createWriter(BiConsumer<String, String> putHeader, Consumer<byte[]> sendBody);
}

Examples