sdk-java/http/basic
github-actions[bot] 7abf0c82ed
Bump to 2.0.0-milestone3 (#246)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-09-29 12:26:16 +02:00
..
src Renamed methods of writes to coerce with the builder apis (#237) 2020-09-28 08:58:57 +02:00
README.md Bump to 2.0.0-milestone3 (#246) 2020-09-29 12:26:16 +02:00
pom.xml Bump to 2.0.0-milestone3 (#246) 2020-09-29 12:26:16 +02: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-milestone3</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: