public final class JacksonResponseConverterFunction extends Object implements ResponseConverterFunction
HttpResponse with
content-type: application/json; charset=utf-8 or content-type: application/json-seq.
The objects published from a Publisher or Stream would be converted into JSON Text Sequences
if a ProducesJsonSequences annotation is specified on an annotated service method.| Constructor and Description |
|---|
JacksonResponseConverterFunction()
Creates an instance with the default
ObjectMapper. |
JacksonResponseConverterFunction(com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates an instance with the specified
ObjectMapper. |
| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
convertResponse(ServiceRequestContext ctx,
ResponseHeaders headers,
Object result,
HttpHeaders trailers)
Returns
HttpResponse instance corresponds to the given result. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfallthroughpublic JacksonResponseConverterFunction()
ObjectMapper.public JacksonResponseConverterFunction(com.fasterxml.jackson.databind.ObjectMapper mapper)
ObjectMapper.public HttpResponse convertResponse(ServiceRequestContext ctx, ResponseHeaders headers, Object result, HttpHeaders trailers) throws Exception
ResponseConverterFunctionHttpResponse instance corresponds to the given result.
Calls ResponseConverterFunction.fallthrough() or throws a FallthroughException if
this converter cannot convert the result to the HttpResponse.convertResponse in interface ResponseConverterFunctionheaders - The HTTP headers that you might want to use to create the HttpResponse.
The status of headers is HttpStatus.OK by default or
HttpStatus.NO_CONTENT if the annotated method returns void,
unless you specify it with StatusCode on the method.
The headers also will include a MediaType if
ServiceRequestContext.negotiatedResponseMediaType() returns it.
If the method returns HttpResult, this headers is the same headers from
HttpResult.headers()
Please note that the additional headers set by
ServiceRequestContext.addAdditionalResponseHeader(CharSequence, Object)
and AdditionalHeader 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 the HttpResponse.
If the annotated method returns HttpResult, this trailers is the same
trailers from HttpResult.trailers().
Please note that the additional trailers set by
ServiceRequestContext.addAdditionalResponseTrailer(CharSequence, Object)
and AdditionalTrailer are not included in this trailers.ExceptionCopyright © 2020 LeanCloud. All rights reserved.