sdk-java/http/basic
Francesco Guardiani b89f45265b
Simplify the Reader/Writer implementations, reducing the knowledge of spec details (#309)
* Messing up stuff

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Collapse CloudEventAttributesWriter and CloudEventAttributesWriter into CloudEventContextWriter

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Rebase fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-01 17:27:50 +01:00
..
src Simplify the Reader/Writer implementations, reducing the knowledge of spec details (#309) 2020-12-01 17:27:50 +01:00
README.md Bump to 2.0.0.RC1 (#305) 2020-11-26 16:34:41 +01:00
pom.xml Bump to 2.0.0-SNAPSHOT (#310) 2020-11-26 16:48:45 +01:00

README.md

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>2.0.0.RC1</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 of usage: