Class ObservableResponseConverterFunction
java.lang.Object
com.linecorp.armeria.server.rxjava3.ObservableResponseConverterFunction
- All Implemented Interfaces:
ResponseConverterFunction
public final class ObservableResponseConverterFunction
extends Object
implements ResponseConverterFunction
A
ResponseConverterFunction
which converts the Observable
instance to a Flowable
first, then converts it to an HttpResponse
using the specified responseConverter
.
The types, which publish 0 or 1 object such as Single
, Maybe
and Completable
,
would not be converted into a Flowable
.-
Constructor Summary
ConstructorDescriptionObservableResponseConverterFunction(ResponseConverterFunction responseConverter)
Creates a newResponseConverterFunction
instance.ObservableResponseConverterFunction(ResponseConverterFunction responseConverter, ExceptionHandlerFunction exceptionHandler)
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionconvertResponse(ServiceRequestContext ctx, ResponseHeaders headers, @Nullable Object result, HttpHeaders trailers)
ReturnsHttpResponse
instance corresponds to the givenresult
.
-
Constructor Details
-
ObservableResponseConverterFunction
@Deprecated public ObservableResponseConverterFunction(ResponseConverterFunction responseConverter, ExceptionHandlerFunction exceptionHandler)Deprecated.The registeredExceptionHandlerFunction
s will be applied automatically. UseObservableResponseConverterFunction(ResponseConverterFunction)
instead.Creates a newResponseConverterFunction
instance.- Parameters:
responseConverter
- the function which converts an object with the configuredResponseConverterFunction
exceptionHandler
- the function which converts aThrowable
with the configuredExceptionHandlerFunction
-
ObservableResponseConverterFunction
Creates a newResponseConverterFunction
instance.- Parameters:
responseConverter
- the function which converts an object with the configuredResponseConverterFunction
-
-
Method Details
-
convertResponse
public HttpResponse convertResponse(ServiceRequestContext ctx, ResponseHeaders headers, @Nullable @Nullable Object result, HttpHeaders trailers) throws ExceptionDescription copied from interface:ResponseConverterFunction
ReturnsHttpResponse
instance corresponds to the givenresult
. CallsResponseConverterFunction.fallthrough()
or throws aFallthroughException
if this converter cannot convert theresult
to theHttpResponse
.- Specified by:
convertResponse
in interfaceResponseConverterFunction
headers
- The HTTP headers that you might want to use to create theHttpResponse
. The status of headers isHttpStatus.OK
by default orHttpStatus.NO_CONTENT
if the annotated method returnsvoid
, unless you specify it withStatusCode
on the method. The headers also will include aMediaType
ifServiceRequestContext.negotiatedResponseMediaType()
returns it. If the method returnsHttpResult
, this headers is the same headers fromHttpResult.headers()
Please note that the additional headers set byServiceRequestContext.mutateAdditionalResponseHeaders(Consumer)
andAdditionalHeader
are not included in this headers.result
- The result of the service method.trailers
- The HTTP trailers that you might want to use to create theHttpResponse
. If the annotated method returnsHttpResult
, this trailers is the same trailers fromHttpResult.trailers()
. Please note that the additional trailers set byServiceRequestContext.mutateAdditionalResponseTrailers(Consumer)
andAdditionalTrailer
are not included in this trailers.- Throws:
Exception
-
ExceptionHandlerFunction
s will be applied automatically.