接口 RestClient.ResponseSpec
- 封闭接口:
- RestClient
public static interface RestClient.ResponseSpec
Contract for specifying response operations following the exchange.
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明<T> Tbody(cn.taketoday.core.ParameterizedTypeReference<T> bodyType) Extract the body as an object of the given type.<T> TExtract the body as an object of the given type.onStatus(ResponseErrorHandler errorHandler) Provide a function to map specific error status codes to an error handler.onStatus(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) Provide a function to map specific error status codes to an error handler.Return aResponseEntitywithout a body.<T> ResponseEntity<T>toEntity(cn.taketoday.core.ParameterizedTypeReference<T> bodyType) Return aResponseEntitywith the body decoded to an Object of the given type.<T> ResponseEntity<T>Return aResponseEntitywith the body decoded to an Object of the given type.
-
方法详细资料
-
onStatus
RestClient.ResponseSpec onStatus(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) Provide a function to map specific error status codes to an error handler.By default, if there are no matching status handlers, responses with status codes >= 400 wil throw a
RestClientResponseException.- 参数:
statusPredicate- to match responses witherrorHandler- handler that typically, though not necessarily, throws an exception- 返回:
- this builder
-
onStatus
Provide a function to map specific error status codes to an error handler.By default, if there are no matching status handlers, responses with status codes >= 400 wil throw a
RestClientResponseException.- 参数:
errorHandler- the error handler- 返回:
- this builder
-
body
Extract the body as an object of the given type.- 类型参数:
T- the body type- 参数:
bodyType- the type of return value- 返回:
- the body, or
nullif no response body was available - 抛出:
RestClientResponseException- by default when receiving a response with a status code of 4xx or 5xx. UseonStatus(Predicate, ErrorHandler)to customize error response handling.
-
body
@Nullable <T> T body(cn.taketoday.core.ParameterizedTypeReference<T> bodyType) Extract the body as an object of the given type.- 类型参数:
T- the body type- 参数:
bodyType- the type of return value- 返回:
- the body, or
nullif no response body was available - 抛出:
RestClientResponseException- by default when receiving a response with a status code of 4xx or 5xx. UseonStatus(Predicate, ErrorHandler)to customize error response handling.
-
toEntity
Return aResponseEntitywith the body decoded to an Object of the given type.- 类型参数:
T- response body type- 参数:
bodyType- the expected response body type- 返回:
- the
ResponseEntitywith the decoded body - 抛出:
RestClientResponseException- by default when receiving a response with a status code of 4xx or 5xx. UseonStatus(Predicate, ErrorHandler)to customize error response handling.
-
toEntity
Return aResponseEntitywith the body decoded to an Object of the given type.- 类型参数:
T- response body type- 参数:
bodyType- the expected response body type- 返回:
- the
ResponseEntitywith the decoded body - 抛出:
RestClientResponseException- by default when receiving a response with a status code of 4xx or 5xx. UseonStatus(Predicate, ErrorHandler)to customize error response handling.
-
toBodilessEntity
ResponseEntity<Void> toBodilessEntity()Return aResponseEntitywithout a body.- 返回:
- the
ResponseEntity - 抛出:
RestClientResponseException- by default when receiving a response with a status code of 4xx or 5xx. UseonStatus(Predicate, ErrorHandler)to customize error response handling.
-