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

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

本文整理了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

  1. private Request getModifyRequest(Request request) {
  2. String xid = RootContext.getXID();
  3. if (StringUtils.isEmpty(xid)) {
  4. return request;
  5. }
  6. Map<String, Collection<String>> headers = new HashMap<>();
  7. headers.putAll(request.headers());
  8. List<String> fescarXid = new ArrayList<>();
  9. fescarXid.add(xid);
  10. headers.put(RootContext.KEY_XID, fescarXid);
  11. return Request.create(request.method(), request.url(), headers, request.body(),
  12. request.charset());
  13. }

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

  1. private Request modifiedRequest(Request request,
  2. Map<String, Collection<String>> headers) {
  3. String method = request.method();
  4. String url = request.url();
  5. byte[] body = request.body();
  6. Charset charset = request.charset();
  7. return Request.create(method, url, headers, body, charset);
  8. }

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

  1. public Request request() {
  2. Map<String, Collection<String>> safeCopy = new LinkedHashMap<String, Collection<String>>();
  3. safeCopy.putAll(headers);
  4. return Request.create(
  5. method,
  6. new StringBuilder(url).append(queryLine()).toString(),
  7. Collections.unmodifiableMap(safeCopy),
  8. body, charset
  9. );
  10. }

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

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

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

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

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

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

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

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

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

  1. private Request modifiedRequest(Request request,
  2. Map<String, Collection<String>> headers) {
  3. String method = request.method();
  4. String url = request.url();
  5. byte[] body = request.body();
  6. Charset charset = request.charset();
  7. return Request.create(method, url, headers, body, charset);
  8. }

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

  1. @Override
  2. public Response execute(Request request, Request.Options options) throws IOException {
  3. Map<String, Collection<String>> traceHeaders = new HashMap<>();
  4. traceHeaders.putAll(request.headers());
  5. Request wrappedRequest =
  6. Request.create(request.method(), request.url(), traceHeaders, request.body(), request.charset());
  7. HttpClientRequest httpClientRequest = new TraceableHttpClientRequest(wrappedRequest);
  8. ClientRequestAdapter adapter = new HttpClientRequestAdapter(httpClientRequest, new DefaultSpanNameProvider());
  9. requestInterceptor.handle(adapter);
  10. Response response = clientDelegate.execute(wrappedRequest, options);
  11. HttpResponse httpResponse = new TraceableHttpClientResponse(response);
  12. ClientResponseAdapter responseAdapter = new HttpClientResponseAdapter(httpResponse);
  13. responseInterceptor.handle(responseAdapter);
  14. return response;
  15. }
  16. }

相关文章