feign.Request.create()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(306)

本文整理了Java中feign.Request.create方法的一些代码示例,展示了Request.create的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.create方法的具体详情如下:
包路径:feign.Request
类名称:Request
方法名:create

Request.create介绍

[英]No parameters can be null except body and charset. All parameters must be effectively immutable, via safe copies, not mutating or otherwise.
[中]除了body和charset之外,任何参数都不能为null。所有参数必须通过安全副本有效地保持不变,而不是突变或其他方式。

代码示例

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

private Request getModifyRequest(Request request) {
  String xid = RootContext.getXID();
  if (StringUtils.isEmpty(xid)) {
    return request;
  }
  Map<String, Collection<String>> headers = new HashMap<>();
  headers.putAll(request.headers());
  List<String> fescarXid = new ArrayList<>();
  fescarXid.add(xid);
  headers.put(RootContext.KEY_XID, fescarXid);
  return Request.create(request.method(), request.url(), headers, request.body(),
      request.charset());
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

private Request modifiedRequest(Request request,
    Map<String, Collection<String>> headers) {
  String method = request.method();
  String url = request.url();
  byte[] body = request.body();
  Charset charset = request.charset();
  return Request.create(method, url, headers, body, charset);
}

代码示例来源:origin: com.netflix.feign/feign-core

public Request request() {
 Map<String, Collection<String>> safeCopy = new LinkedHashMap<String, Collection<String>>();
 safeCopy.putAll(headers);
 return Request.create(
   method,
   new StringBuilder(url).append(queryLine()).toString(),
   Collections.unmodifiableMap(safeCopy),
   body, charset
 );
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

private Request toRequest(Request request) {
  Map<String, Collection<String>> headers = new LinkedHashMap<>(
      request.headers());
  return Request.create(request.httpMethod(), getUri().toASCIIString(), headers,
      request.requestBody());
}

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

private Request toRequest(Request request) {
  Map<String, Collection<String>> headers = new LinkedHashMap<>(
      request.headers());
  return Request.create(request.httpMethod(), getUri().toASCIIString(), headers,
      request.requestBody());
}

代码示例来源:origin: wso2/msf4j

private Request tracePreRequest(Request request, TraceEvent traceEvent) {
  // set tracing headers to HTTP request
  Map<String, Collection<String>> traceHeaders = new HashMap<>();
  traceHeaders.putAll(request.headers());
  traceHeaders.put(TracingConstants.TRACE_ID_HEADER, Collections.singletonList(traceEvent.getTraceId()));
  traceHeaders.put(TracingConstants.TRACE_ORIGIN_ID_HEADER, Collections.singletonList(traceEvent.getOriginId()));
  // publish event to DAS
  TracingUtil.pushToDAS(traceEvent, dasUrl);
  return Request.create(request.method(), request.url(), traceHeaders, request.body(), request.charset());
}

代码示例来源:origin: spring-cloud/spring-cloud-zookeeper

private Request request(Request request,
    Map<String, Collection<String>> headers) {
  return Request.create(request.method(), request.url(), headers,
      request.body(), request.charset());
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

private Request modifiedRequest(Request request,
    Map<String, Collection<String>> headers) {
  String method = request.method();
  String url = request.url();
  byte[] body = request.body();
  Charset charset = request.charset();
  return Request.create(method, url, headers, body, charset);
}

代码示例来源:origin: wso2/msf4j

@Override
  public Response execute(Request request, Request.Options options) throws IOException {
    Map<String, Collection<String>> traceHeaders = new HashMap<>();
    traceHeaders.putAll(request.headers());
    Request wrappedRequest =
        Request.create(request.method(), request.url(), traceHeaders, request.body(), request.charset());
    HttpClientRequest httpClientRequest = new TraceableHttpClientRequest(wrappedRequest);
    ClientRequestAdapter adapter = new HttpClientRequestAdapter(httpClientRequest, new DefaultSpanNameProvider());
    requestInterceptor.handle(adapter);

    Response response = clientDelegate.execute(wrappedRequest, options);

    HttpResponse httpResponse = new TraceableHttpClientResponse(response);
    ClientResponseAdapter responseAdapter = new HttpClientResponseAdapter(httpResponse);
    responseInterceptor.handle(responseAdapter);
    return response;
  }
}

相关文章