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

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

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

Request.url介绍

暂无

代码示例

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

@Override
public String url(Request request) {
  return request.url();
}

代码示例来源: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: org.springframework.cloud/spring-cloud-sleuth-core

@Override
public String url(Request request) {
  return request.url();
}

代码示例来源:origin: com.ofg/micro-infra-spring-base

static String extractUrl(Request request) {
  return request.url();
}

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

@Override
public URI getUri() {
  return URI.create(request.url());
}

代码示例来源:origin: com.marvinformatics.feign/feign-mock

private static String buildUrl(Request request) {
  try {
    return URLDecoder.decode(request.url(), Util.UTF_8.name());
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.ofg/micro-infra-spring-base

static String extractPath(Request request) {
  return URI.create(request.url()).getPath();
}

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

static FeignException errorReading(Request request, Response ignored, IOException cause) {
 return new FeignException(
   format("%s reading %s %s", cause.getMessage(), request.method(), request.url()),
   cause);
}

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

static FeignException errorExecuting(Request request, IOException cause) {
  return new RetryableException(
    format("%s executing %s %s", cause.getMessage(), request.method(), request.url()), cause,
    null);
 }
}

代码示例来源:origin: io.github.openfeign/feign-httpclient

@Override
public Response execute(Request request, Request.Options options) throws IOException {
 HttpUriRequest httpUriRequest;
 try {
  httpUriRequest = toHttpUriRequest(request, options);
 } catch (URISyntaxException e) {
  throw new IOException("URL '" + request.url() + "' couldn't be parsed into a URI", e);
 }
 HttpResponse httpResponse = client.execute(httpUriRequest);
 return toFeignResponse(httpResponse, request);
}

代码示例来源: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: bbilger/jrestless

@BeforeEach
public void setup() throws UnsupportedEncodingException {
  when(feignRequest.url()).thenReturn("/");
  when(feignRequest.method()).thenReturn("GET");
  when(serviceResponse.getStatusCode()).thenReturn(200);
}

代码示例来源:origin: bbilger/jrestless

private static ServiceRequest toServiceRequest(feign.Request feignRequest) {
  return new DefaultServiceRequest(toServiceBody(feignRequest.body()), toServiceHeaders(feignRequest.headers()),
      URI.create(feignRequest.url()), feignRequest.method());
}

代码示例来源:origin: ppdai-incubator/raptor

protected void preHandle(Request request, Request.Options options) throws Exception {
  //设置url和method到Context中,方便其他地方取
  RaptorContext.getContext().putAttribute(NAME_HTTP_URI, UrlUtils.getUri(request.url()));
  RaptorContext.getContext().putAttribute(NAME_HTTP_METHOD, request.method());
}

代码示例来源:origin: bbilger/jrestless

@Test
public void execute_NoRequestUrlGiven_ShouldFail() throws IOException {
  FeignLambdaClientImpl client = new FeignLambdaClientImpl(serviceResponse);
  when(feignRequest.url()).thenReturn(null);
  assertThrows(NullPointerException.class, () -> client.execute(feignRequest, null));
}

代码示例来源:origin: forgemo/bittrex-java-client

private void signRequestsIfCredentialsNotNull(Feign.Builder builder, @Nullable ApiCredentials credentials){
    if (credentials != null) {
      RequestInterceptor signAllRequests = requestTemplate -> {

        requestTemplate.query("apikey", credentials.getKey());
        requestTemplate.query("nonce", ApiKeySigningUtil.createNonce());

        String requestUrl = baseUrl+requestTemplate.request().url();
        String sign = ApiKeySigningUtil.createSign(requestUrl, credentials.getSecret());
        requestTemplate.header("apisign", sign);
      };

      builder.requestInterceptor(signAllRequests);
    }
  }
}

代码示例来源:origin: bbilger/jrestless

@Test
public void execute_RequestUrlGiven_ShouldRequestWithUrl() throws IOException {
  FeignLambdaClientImpl client = new FeignLambdaClientImpl(serviceResponse);
  when(feignRequest.url()).thenReturn("/whatever?a=b&c=d");
  client.execute(feignRequest, null);
  assertEquals(URI.create("/whatever?a=b&c=d"), client.getServiceRequest().getRequestUri());
}

相关文章