类 NacosRestTemplate
- java.lang.Object
-
- com.alibaba.nacos.common.http.client.AbstractNacosRestTemplate
-
- com.alibaba.nacos.common.http.client.NacosRestTemplate
-
public class NacosRestTemplate extends AbstractNacosRestTemplate
Nacos rest template Interface specifying a basic set of RESTful operations.- 作者:
- mai.jh
- 另请参阅:
HttpClientRequest,HttpClientResponse
-
-
字段概要
字段 修饰符和类型 字段 说明 private java.util.List<HttpClientRequestInterceptor>interceptorsprivate HttpClientRequestrequestClient-
从类继承的字段 com.alibaba.nacos.common.http.client.AbstractNacosRestTemplate
logger
-
-
构造器概要
构造器 构造器 说明 NacosRestTemplate(org.slf4j.Logger logger, HttpClientRequest requestClient)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidclose()close request client.<T> HttpRestResult<T>delete(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.reflect.Type responseType)http delete URL request params are expanded using the given queryQuery.<T> HttpRestResult<T>delete(java.lang.String url, Header header, Query query, java.lang.reflect.Type responseType)http delete URL request params are expanded using the given queryQuery.<T> HttpRestResult<T>exchange(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.Object body, java.lang.String httpMethod, java.lang.reflect.Type responseType)Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asHttpRestResult.<T> HttpRestResult<T>exchangeForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.String httpMethod, java.lang.reflect.Type responseType)Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asHttpRestResult.private <T> HttpRestResult<T>execute(java.lang.String url, java.lang.String httpMethod, RequestHttpEntity requestEntity, java.lang.reflect.Type responseType)<T> HttpRestResult<T>get(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.reflect.Type responseType)http get URL request params are expanded using the given queryQuery.<T> HttpRestResult<T>get(java.lang.String url, Header header, Query query, java.lang.reflect.Type responseType)http get URL request params are expanded using the given queryQuery.java.util.List<HttpClientRequestInterceptor>getInterceptors()Return the request interceptors that this accessor uses.<T> HttpRestResult<T>getLarge(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType)get request, may be pulling a lot of data URL request params are expanded using the given queryQuery, More request parameters can be set via body.<T> HttpRestResult<T>post(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType)http post Create a new resource by POSTing the given object to the http request.<T> HttpRestResult<T>postForm(java.lang.String url, HttpClientConfig config, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>postForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>postForm(java.lang.String url, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>postJson(java.lang.String url, Header header, Query query, java.lang.String body, java.lang.reflect.Type responseType)http post json Create a new resource by POSTing the given object to the http request, http header contentType default 'application/json;charset=UTF-8'.<T> HttpRestResult<T>postJson(java.lang.String url, Header header, java.lang.String body, java.lang.reflect.Type responseType)http post json Create a new resource by POSTing the given object to the http request, http header contentType default 'application/json;charset=UTF-8'.<T> HttpRestResult<T>put(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType)http put Create a new resource by PUTting the given body to http request.<T> HttpRestResult<T>putForm(java.lang.String url, HttpClientConfig config, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>putForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>putForm(java.lang.String url, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType)http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.<T> HttpRestResult<T>putJson(java.lang.String url, Header header, Query query, java.lang.String body, java.lang.reflect.Type responseType)http put json Create a new resource by PUTting the given body to http request, http header contentType default 'application/json;charset=UTF-8'.<T> HttpRestResult<T>putJson(java.lang.String url, Header header, java.lang.String body, java.lang.reflect.Type responseType)http put json Create a new resource by PUTting the given body to http request, http header contentType default 'application/json;charset=UTF-8'.private HttpClientRequestrequestClient()voidsetInterceptors(java.util.List<HttpClientRequestInterceptor> interceptors)Set the request interceptors that this accessor should use.-
从类继承的方法 com.alibaba.nacos.common.http.client.AbstractNacosRestTemplate
registerResponseHandler, selectResponseHandler
-
-
-
-
字段详细资料
-
requestClient
private final HttpClientRequest requestClient
-
interceptors
private final java.util.List<HttpClientRequestInterceptor> interceptors
-
-
构造器详细资料
-
NacosRestTemplate
public NacosRestTemplate(org.slf4j.Logger logger, HttpClientRequest requestClient)
-
-
方法详细资料
-
get
public <T> HttpRestResult<T> get(java.lang.String url, Header header, Query query, java.lang.reflect.Type responseType) throws java.lang.Exception
http get URL request params are expanded using the given queryQuery.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
get
public <T> HttpRestResult<T> get(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.reflect.Type responseType) throws java.lang.Exception
http get URL request params are expanded using the given queryQuery.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.configSpecify the request config viaHttpClientConfig- 参数:
url- urlconfig- http configheader- headersquery- http query paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
getLarge
public <T> HttpRestResult<T> getLarge(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType) throws java.lang.Exception
get request, may be pulling a lot of data URL request params are expanded using the given queryQuery, More request parameters can be set via body.This method can only be used when HttpClientRequest is implemented by
DefaultHttpClientRequest, note:JdkHttpClientRequestImplementation does not support this method.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambody- get with bodyresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
delete
public <T> HttpRestResult<T> delete(java.lang.String url, Header header, Query query, java.lang.reflect.Type responseType) throws java.lang.Exception
http delete URL request params are expanded using the given queryQuery.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
delete
public <T> HttpRestResult<T> delete(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.reflect.Type responseType) throws java.lang.Exception
http delete URL request params are expanded using the given queryQuery.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.configSpecify the request config viaHttpClientConfig- 参数:
url- urlconfig- http configheader- http header paramquery- http query paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
put
public <T> HttpRestResult<T> put(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType) throws java.lang.Exception
http put Create a new resource by PUTting the given body to http request.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
putJson
public <T> HttpRestResult<T> putJson(java.lang.String url, Header header, Query query, java.lang.String body, java.lang.reflect.Type responseType) throws java.lang.Exception
http put json Create a new resource by PUTting the given body to http request, http header contentType default 'application/json;charset=UTF-8'.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
putJson
public <T> HttpRestResult<T> putJson(java.lang.String url, Header header, java.lang.String body, java.lang.reflect.Type responseType) throws java.lang.Exception
http put json Create a new resource by PUTting the given body to http request, http header contentType default 'application/json;charset=UTF-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
putForm
public <T> HttpRestResult<T> putForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
putForm
public <T> HttpRestResult<T> putForm(java.lang.String url, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
putForm
public <T> HttpRestResult<T> putForm(java.lang.String url, HttpClientConfig config, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http put from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.configSpecify the request config viaHttpClientConfig- 参数:
url- urlconfig- http configheader- http header parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
post
public <T> HttpRestResult<T> post(java.lang.String url, Header header, Query query, java.lang.Object body, java.lang.reflect.Type responseType) throws java.lang.Exception
http post Create a new resource by POSTing the given object to the http request.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
postJson
public <T> HttpRestResult<T> postJson(java.lang.String url, Header header, Query query, java.lang.String body, java.lang.reflect.Type responseType) throws java.lang.Exception
http post json Create a new resource by POSTing the given object to the http request, http header contentType default 'application/json;charset=UTF-8'.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
postJson
public <T> HttpRestResult<T> postJson(java.lang.String url, Header header, java.lang.String body, java.lang.reflect.Type responseType) throws java.lang.Exception
http post json Create a new resource by POSTing the given object to the http request, http header contentType default 'application/json;charset=UTF-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header parambody- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
postForm
public <T> HttpRestResult<T> postForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.URL request params are expanded using the given query
Query.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header paramquery- http query parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
postForm
public <T> HttpRestResult<T> postForm(java.lang.String url, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.- 参数:
url- urlheader- http header parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
postForm
public <T> HttpRestResult<T> postForm(java.lang.String url, HttpClientConfig config, Header header, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.reflect.Type responseType) throws java.lang.Exception
http post from Create a new resource by PUTting the given mapbodyValuesto http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.responseTypecan be an HttpRestResult or HttpRestResult dataTtype.configSpecify the request config viaHttpClientConfig- 参数:
url- urlconfig- http configheader- http header parambodyValues- http body paramresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
exchangeForm
public <T> HttpRestResult<T> exchangeForm(java.lang.String url, Header header, Query query, java.util.Map<java.lang.String,java.lang.String> bodyValues, java.lang.String httpMethod, java.lang.reflect.Type responseType) throws java.lang.Exception
Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asHttpRestResult.- 参数:
url- urlheader- http header paramquery- http query parambodyValues- http body paramhttpMethod- http methodresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
exchange
public <T> HttpRestResult<T> exchange(java.lang.String url, HttpClientConfig config, Header header, Query query, java.lang.Object body, java.lang.String httpMethod, java.lang.reflect.Type responseType) throws java.lang.Exception
Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asHttpRestResult.- 参数:
url- urlconfig- HttpClientConfigheader- http header paramquery- http query parambody- http body paramhttpMethod- http methodresponseType- return type- 返回:
HttpRestResult- 抛出:
java.lang.Exception- ex
-
setInterceptors
public void setInterceptors(java.util.List<HttpClientRequestInterceptor> interceptors)
Set the request interceptors that this accessor should use.- 参数:
interceptors-HttpClientRequestInterceptor
-
getInterceptors
public java.util.List<HttpClientRequestInterceptor> getInterceptors()
Return the request interceptors that this accessor uses.The returned
Listis active and may get appended to.
-
execute
private <T> HttpRestResult<T> execute(java.lang.String url, java.lang.String httpMethod, RequestHttpEntity requestEntity, java.lang.reflect.Type responseType) throws java.lang.Exception
- 抛出:
java.lang.Exception
-
requestClient
private HttpClientRequest requestClient()
-
close
public void close() throws java.lang.Exceptionclose request client.- 抛出:
java.lang.Exception
-
-