Class JsonTextSequences
java.lang.Object
com.linecorp.armeria.server.streaming.JsonTextSequences
A utility class which helps to create a JavaScript Object
Notation (JSON) Text Sequences from a content
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();
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpResponsefromObject(ResponseHeaders headers, @Nullable Object content) Creates a new JSON Text Sequences of the specifiedcontent.static HttpResponsefromObject(ResponseHeaders headers, @Nullable Object content, ObjectMapper mapper) Creates a new JSON Text Sequences of the specifiedcontent.static HttpResponsefromObject(ResponseHeaders headers, @Nullable Object content, HttpHeaders trailers, ObjectMapper mapper) Creates a new JSON Text Sequences of the specifiedcontent.static HttpResponsefromObject(@Nullable Object content) Creates a new JSON Text Sequences of the specifiedcontent.static HttpResponsefromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher) Creates a new JSON Text Sequences from the specifiedPublisher.static HttpResponsefromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.static HttpResponsefromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, HttpHeaders trailers, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.static HttpResponsefromPublisher(org.reactivestreams.Publisher<?> contentPublisher) Creates a new JSON Text Sequences from the specifiedPublisher.static HttpResponsefromPublisher(org.reactivestreams.Publisher<?> contentPublisher, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.static HttpResponsefromStream(ResponseHeaders headers, Stream<?> contentStream, HttpHeaders trailers, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.static HttpResponsefromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor) Creates a new JSON Text Sequences from the specifiedStream.static HttpResponsefromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.static HttpResponsefromStream(Stream<?> contentStream, Executor executor) Creates a new JSON Text Sequences from the specifiedStream.static HttpResponsefromStream(Stream<?> contentStream, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.
-
Method Details
-
fromPublisher
Creates a new JSON Text Sequences from the specifiedPublisher.- Parameters:
contentPublisher- thePublisherwhich publishes the objects supposed to send as contents
-
fromPublisher
public static HttpResponse fromPublisher(org.reactivestreams.Publisher<?> contentPublisher, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.- Parameters:
contentPublisher- thePublisherwhich publishes the objects supposed to send as contentsmapper- the mapper which converts the content object into JSON Text Sequences
-
fromPublisher
public static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher) Creates a new JSON Text Sequences from the specifiedPublisher.- Parameters:
headers- the HTTP headers supposed to sendcontentPublisher- thePublisherwhich publishes the objects supposed to send as contents
-
fromPublisher
public static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.- Parameters:
headers- the HTTP headers supposed to sendcontentPublisher- thePublisherwhich publishes the objects supposed to send as contentsmapper- the mapper which converts the content object into JSON Text Sequences
-
fromPublisher
public static HttpResponse fromPublisher(ResponseHeaders headers, org.reactivestreams.Publisher<?> contentPublisher, HttpHeaders trailers, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedPublisher.- Parameters:
headers- the HTTP headers supposed to sendcontentPublisher- thePublisherwhich publishes the objects supposed to send as contentstrailers- the HTTP trailersmapper- the mapper which converts the content object into JSON Text Sequences
-
fromStream
Creates a new JSON Text Sequences from the specifiedStream.- Parameters:
contentStream- theStreamwhich publishes the objects supposed to send as contentsexecutor- the executor which iterates the stream
-
fromStream
public static HttpResponse fromStream(Stream<?> contentStream, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.- Parameters:
contentStream- theStreamwhich publishes the objects supposed to send as contentsexecutor- the executor which iterates the stream
-
fromStream
public static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor) Creates a new JSON Text Sequences from the specifiedStream.- Parameters:
headers- the HTTP headers supposed to sendcontentStream- theStreamwhich publishes the objects supposed to send as contentsexecutor- the executor which iterates the stream
-
fromStream
public static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.- Parameters:
headers- the HTTP headers supposed to sendcontentStream- theStreamwhich publishes the objects supposed to send as contentsexecutor- the executor which iterates the streammapper- the mapper which converts the content object into JSON Text Sequences
-
fromStream
public static HttpResponse fromStream(ResponseHeaders headers, Stream<?> contentStream, HttpHeaders trailers, Executor executor, ObjectMapper mapper) Creates a new JSON Text Sequences from the specifiedStream.- Parameters:
headers- the HTTP headers supposed to sendcontentStream- theStreamwhich 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 Sequences
-
fromObject
Creates a new JSON Text Sequences of the specifiedcontent.- Parameters:
content- the object supposed to send as contents
-
fromObject
Creates a new JSON Text Sequences of the specifiedcontent.- Parameters:
headers- the HTTP headers supposed to sendcontent- the object supposed to send as contents
-
fromObject
public static HttpResponse fromObject(ResponseHeaders headers, @Nullable @Nullable Object content, ObjectMapper mapper) Creates a new JSON Text Sequences of the specifiedcontent.- Parameters:
headers- the HTTP headers supposed to sendcontent- the object supposed to send as contentsmapper- the mapper which converts the content object into JSON Text Sequences
-
fromObject
public static HttpResponse fromObject(ResponseHeaders headers, @Nullable @Nullable Object content, HttpHeaders trailers, ObjectMapper mapper) Creates a new JSON Text Sequences of the specifiedcontent.- Parameters:
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 Sequences
-