接口 RestClient.ResponseSpec

所有已知实现类:
DefaultRestClient.DefaultResponseSpec
封闭接口:
RestClient

public static interface RestClient.ResponseSpec
Contract for specifying response operations following the exchange.
  • 方法详细资料

    • 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.

      参数:
      statusPredicate - to match responses with
      errorHandler - 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

      @Nullable <T> T body(Class<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 null if no response body was available
      抛出:
      RestClientResponseException - by default when receiving a response with a status code of 4xx or 5xx. Use onStatus(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 null if no response body was available
      抛出:
      RestClientResponseException - by default when receiving a response with a status code of 4xx or 5xx. Use onStatus(Predicate, ErrorHandler) to customize error response handling.
    • toEntity

      <T> ResponseEntity<T> toEntity(Class<T> bodyType)
      Return a ResponseEntity with the body decoded to an Object of the given type.
      类型参数:
      T - response body type
      参数:
      bodyType - the expected response body type
      返回:
      the ResponseEntity with the decoded body
      抛出:
      RestClientResponseException - by default when receiving a response with a status code of 4xx or 5xx. Use onStatus(Predicate, ErrorHandler) to customize error response handling.
    • toEntity

      <T> ResponseEntity<T> toEntity(cn.taketoday.core.ParameterizedTypeReference<T> bodyType)
      Return a ResponseEntity with the body decoded to an Object of the given type.
      类型参数:
      T - response body type
      参数:
      bodyType - the expected response body type
      返回:
      the ResponseEntity with the decoded body
      抛出:
      RestClientResponseException - by default when receiving a response with a status code of 4xx or 5xx. Use onStatus(Predicate, ErrorHandler) to customize error response handling.
    • toBodilessEntity

      ResponseEntity<Void> toBodilessEntity()
      Return a ResponseEntity without a body.
      返回:
      the ResponseEntity
      抛出:
      RestClientResponseException - by default when receiving a response with a status code of 4xx or 5xx. Use onStatus(Predicate, ErrorHandler) to customize error response handling.