@FunctionalInterface public interface ResponseConverterFunction
result object to HttpResponse. The class implementing this interface would
be specified as ResponseConverter annotation.ResponseConverter| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
convertResponse(ServiceRequestContext ctx,
ResponseHeaders headers,
Object result,
HttpHeaders trailers)
Returns
HttpResponse instance corresponds to the given result. |
static <T> T |
fallthrough()
Throws a
FallthroughException in order to try to convert result to
HttpResponse by the next converter. |
HttpResponse convertResponse(ServiceRequestContext ctx, ResponseHeaders headers, Object result, HttpHeaders trailers) throws Exception
HttpResponse instance corresponds to the given result.
Calls fallthrough() or throws a FallthroughException if
this converter cannot convert the result to the HttpResponse.headers - 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.Exceptionstatic <T> T fallthrough()
FallthroughException in order to try to convert result to
HttpResponse by the next converter.Copyright © 2020 LeanCloud. All rights reserved.