Class RestClient
java.lang.Object
com.flyfish.oauth.client.RestClient
Rest请求客户端
- Author:
- Mr.Wang
1. 全builder调用,用户系统内部相互通信 2. 支持异步回调 3. 多样性组合 4. 解耦实现
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class主要的builder,核心构建static class异常类,用于包装异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic RestClient.RestClientBuildercreate()static voiddestroy()销毁单例资源<T> Texecute()执行请求,返回响应实体,自行处理<T> Texecute(com.fasterxml.jackson.core.type.TypeReference<T> typeReference) 执行请求,根据type引用实例化void异步执行,接收结果执行请求,返回Map执行请求,返回字符串onError(Consumer<RestClient.RestClientException> errorConsumer) 设置请求失败时的回调responseType(com.flyfish.oauth.client.RestClient.ResponseType responseType) 设置响应类型
-
Method Details
-
create
-
destroy
public static void destroy()销毁单例资源 -
onError
设置请求失败时的回调- Parameters:
errorConsumer- 错误回调- Returns:
- 结果
-
responseType
设置响应类型- Parameters:
responseType- 响应类型- Returns:
- 结果
-
execute
异步执行,接收结果- Parameters:
consumer- 结果
-
executeForMap
执行请求,返回Map- Returns:
- map
- Throws:
IOException- 异常
-
executeForString
执行请求,返回字符串- Returns:
- 字符串
- Throws:
IOException- 异常
-
execute
-
execute
public <T> T execute(com.fasterxml.jackson.core.type.TypeReference<T> typeReference) 执行请求,根据type引用实例化- Type Parameters:
T- 泛型- Parameters:
typeReference- 类型引用- Returns:
- 结果
-