public final class JsonTextSequences extends Object
Publisher or Stream.
A user simply creates a streaming HttpResponse which emits JSON Text Sequences, e.g.
ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
Server server =
Server.builder()
// Emit JSON Text Sequences with a default ObjectMapper.
.service("/seq1",
(ctx, req) -> JsonTextSequences.fromPublisher(Flux.just("foo", "bar")))
// Emit JSON Text Sequences with the ObjectMapper
// configured to use the default pretty printer.
.service("/seq2",
(ctx, req) -> JsonTextSequences.fromPublisher(Flux.just("foo", "bar"), mapper))
.build();
| Modifier and Type | Method and Description |
|---|---|
static HttpResponse |
fromObject(Object content)
Creates a new JSON Text Sequences of the specified
content. |
static HttpResponse |
fromObject(ResponseHeaders headers,
Object content)
Creates a new JSON Text Sequences of the specified
content. |
static HttpResponse |
fromObject(ResponseHeaders headers,
Object content,
HttpHeaders trailers,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences of the specified
content. |
static HttpResponse |
fromObject(ResponseHeaders headers,
Object content,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences of the specified
content. |
static HttpResponse |
fromPublisher(org.reactivestreams.Publisher<?> contentPublisher)
Creates a new JSON Text Sequences from the specified
Publisher. |
static HttpResponse |
fromPublisher(org.reactivestreams.Publisher<?> contentPublisher,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Publisher. |
static HttpResponse |
fromPublisher(ResponseHeaders headers,
org.reactivestreams.Publisher<?> contentPublisher)
Creates a new JSON Text Sequences from the specified
Publisher. |
static HttpResponse |
fromPublisher(ResponseHeaders headers,
org.reactivestreams.Publisher<?> contentPublisher,
HttpHeaders trailers,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Publisher. |
static HttpResponse |
fromPublisher(ResponseHeaders headers,
org.reactivestreams.Publisher<?> contentPublisher,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Publisher. |
static HttpResponse |
fromStream(ResponseHeaders headers,
Stream<?> contentStream,
Executor executor)
Creates a new JSON Text Sequences from the specified
Stream. |
static HttpResponse |
fromStream(ResponseHeaders headers,
Stream<?> contentStream,
Executor executor,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Stream. |
static HttpResponse |
fromStream(ResponseHeaders headers,
Stream<?> contentStream,
HttpHeaders trailers,
Executor executor,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Stream. |
static HttpResponse |
fromStream(Stream<?> contentStream,
Executor executor)
Creates a new JSON Text Sequences from the specified
Stream. |
static HttpResponse |
fromStream(Stream<?> contentStream,
Executor executor,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new JSON Text Sequences from the specified
Stream. |
public static HttpResponse fromPublisher(org.reactivestreams.Publisher<?> contentPublisher)
Publisher.contentPublisher - the Publisher which publishes the objects supposed to send as contentspublic static HttpResponse fromPublisher(org.reactivestreams.Publisher<?> contentPublisher, com.fasterxml.jackson.databind.ObjectMapper mapper)
Publisher.contentPublisher - the Publisher which publishes the objects supposed to send as contentsmapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher)
Publisher.headers - the HTTP headers supposed to sendcontentPublisher - the Publisher which publishes the objects supposed to send as contentspublic static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, com.fasterxml.jackson.databind.ObjectMapper mapper)
Publisher.headers - the HTTP headers supposed to sendcontentPublisher - the Publisher which publishes the objects supposed to send as contentsmapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, HttpHeaders trailers, com.fasterxml.jackson.databind.ObjectMapper mapper)
Publisher.headers - the HTTP headers supposed to sendcontentPublisher - the Publisher which publishes the objects supposed to send as contentstrailers - the HTTP trailersmapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromStream(Stream<?> contentStream, Executor executor)
Stream.contentStream - the Stream which publishes the objects supposed to send as contentsexecutor - the executor which iterates the streampublic static HttpResponse fromStream(Stream<?> contentStream, Executor executor, com.fasterxml.jackson.databind.ObjectMapper mapper)
Stream.contentStream - the Stream which publishes the objects supposed to send as contentsexecutor - the executor which iterates the streampublic static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor)
Stream.headers - the HTTP headers supposed to sendcontentStream - the Stream which publishes the objects supposed to send as contentsexecutor - the executor which iterates the streampublic static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor, com.fasterxml.jackson.databind.ObjectMapper mapper)
Stream.headers - the HTTP headers supposed to sendcontentStream - the Stream which publishes the objects supposed to send as contentsexecutor - the executor which iterates the streammapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, HttpHeaders trailers, Executor executor, com.fasterxml.jackson.databind.ObjectMapper mapper)
Stream.headers - the HTTP headers supposed to sendcontentStream - the Stream which publishes the objects supposed to send as contentstrailers - the HTTP trailersexecutor - the executor which iterates the streammapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromObject(Object content)
content.content - the object supposed to send as contentspublic static HttpResponse fromObject(ResponseHeaders headers, Object content)
content.headers - the HTTP headers supposed to sendcontent - the object supposed to send as contentspublic static HttpResponse fromObject(ResponseHeaders headers, Object content, com.fasterxml.jackson.databind.ObjectMapper mapper)
content.headers - the HTTP headers supposed to sendcontent - the object supposed to send as contentsmapper - the mapper which converts the content object into JSON Text Sequencespublic static HttpResponse fromObject(ResponseHeaders headers, Object content, HttpHeaders trailers, com.fasterxml.jackson.databind.ObjectMapper mapper)
content.headers - the HTTP headers supposed to sendcontent - the object supposed to send as contentstrailers - the HTTP trailersmapper - the mapper which converts the content object into JSON Text SequencesCopyright © 2020 LeanCloud. All rights reserved.