类 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
  • 构造器详细资料

    • NacosRestTemplate

      public NacosRestTemplate(org.slf4j.Logger logger, HttpClientRequest requestClient)
  • 方法详细资料

    • get

      public <T> HttpRestResult<T> get(String url, Header header, Query query, Type responseType) throws Exception
      http get URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • get

      public <T> HttpRestResult<T> get(String url, HttpClientConfig config, Header header, Query query, Type responseType) throws Exception
      http get URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      config Specify the request config via HttpClientConfig

      参数:
      url - url
      config - http config
      header - headers
      query - http query param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • getLarge

      public <T> HttpRestResult<T> getLarge(String url, Header header, Query query, Object body, Type responseType) throws Exception
      get request, may be pulling a lot of data URL request params are expanded using the given query Query, More request parameters can be set via body.

      This method can only be used when HttpClientRequest is implemented by DefaultHttpClientRequest, note: JdkHttpClientRequest Implementation does not support this method.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      body - get with body
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • delete

      public <T> HttpRestResult<T> delete(String url, Header header, Query query, Type responseType) throws Exception
      http delete URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • delete

      public <T> HttpRestResult<T> delete(String url, HttpClientConfig config, Header header, Query query, Type responseType) throws Exception
      http delete URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      config Specify the request config via HttpClientConfig

      参数:
      url - url
      config - http config
      header - http header param
      query - http query param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • put

      public <T> HttpRestResult<T> put(String url, Header header, Query query, Object body, Type responseType) throws 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.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • putJson

      public <T> HttpRestResult<T> putJson(String url, Header header, Query query, String body, Type responseType) throws 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.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • putJson

      public <T> HttpRestResult<T> putJson(String url, Header header, String body, Type responseType) throws 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'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • putForm

      public <T> HttpRestResult<T> putForm(String url, Header header, Query query, Map<String,​String> bodyValues, Type responseType) throws Exception
      http put from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • putForm

      public <T> HttpRestResult<T> putForm(String url, Header header, Map<String,​String> bodyValues, Type responseType) throws Exception
      http put from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • putForm

      public <T> HttpRestResult<T> putForm(String url, HttpClientConfig config, Header header, Map<String,​String> bodyValues, Type responseType) throws Exception
      http put from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      config Specify the request config via HttpClientConfig

      参数:
      url - url
      config - http config
      header - http header param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • post

      public <T> HttpRestResult<T> post(String url, Header header, Query query, Object body, Type responseType) throws 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.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • postJson

      public <T> HttpRestResult<T> postJson(String url, Header header, Query query, String body, Type responseType) throws 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.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • postJson

      public <T> HttpRestResult<T> postJson(String url, Header header, String body, Type responseType) throws 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'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      body - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • postForm

      public <T> HttpRestResult<T> postForm(String url, Header header, Query query, Map<String,​String> bodyValues, Type responseType) throws Exception
      http post from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      URL request params are expanded using the given query Query.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      query - http query param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • postForm

      public <T> HttpRestResult<T> postForm(String url, Header header, Map<String,​String> bodyValues, Type responseType) throws Exception
      http post from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      参数:
      url - url
      header - http header param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • postForm

      public <T> HttpRestResult<T> postForm(String url, HttpClientConfig config, Header header, Map<String,​String> bodyValues, Type responseType) throws Exception
      http post from Create a new resource by PUTting the given map bodyValues to http request, http header contentType default 'application/x-www-form-urlencoded;charset=utf-8'.

      responseType can be an HttpRestResult or HttpRestResult data T type.

      config Specify the request config via HttpClientConfig

      参数:
      url - url
      config - http config
      header - http header param
      bodyValues - http body param
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • exchangeForm

      public <T> HttpRestResult<T> exchangeForm(String url, Header header, Query query, Map<String,​String> bodyValues, String httpMethod, Type responseType) throws Exception
      Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as HttpRestResult.
      参数:
      url - url
      header - http header param
      query - http query param
      bodyValues - http body param
      httpMethod - http method
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • exchange

      public <T> HttpRestResult<T> exchange(String url, HttpClientConfig config, Header header, Query query, Object body, String httpMethod, Type responseType) throws Exception
      Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as HttpRestResult.
      参数:
      url - url
      config - HttpClientConfig
      header - http header param
      query - http query param
      body - http body param
      httpMethod - http method
      responseType - return type
      返回:
      HttpRestResult
      抛出:
      Exception - ex
    • setInterceptors

      public void setInterceptors(List<HttpClientRequestInterceptor> interceptors)
      Set the request interceptors that this accessor should use.
      参数:
      interceptors - HttpClientRequestInterceptor
    • getInterceptors

      public List<HttpClientRequestInterceptor> getInterceptors()
      Return the request interceptors that this accessor uses.

      The returned List is active and may get appended to.

    • close

      public void close() throws Exception
      close request client.
      抛出:
      Exception