当前位置: 首页>>代码示例>>Java>>正文


Java UriComponentsBuilder.fromUriString方法代码示例

本文整理汇总了Java中org.springframework.web.util.UriComponentsBuilder.fromUriString方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponentsBuilder.fromUriString方法的具体用法?Java UriComponentsBuilder.fromUriString怎么用?Java UriComponentsBuilder.fromUriString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.util.UriComponentsBuilder的用法示例。


在下文中一共展示了UriComponentsBuilder.fromUriString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupHttpClient

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
private void setupHttpClient(String connectionToken, String protocolVersion){

 if(client != null){
  client.close();
 }
 
 UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromUriString("/signalr/connect");
	  urlBuilder.queryParam("transport", "webSockets");
	  urlBuilder.queryParam("clientProtocol", protocolVersion);
	  urlBuilder.queryParam("connectionToken", connectionToken);
	  urlBuilder.queryParam("connectionData", "[{\"name\":\"corehub\"}]");
	
	  String endPoint = urlBuilder.build().encode().toUriString();
 
 HttpClientOptions options = new HttpClientOptions();
 
 options.setMaxWebsocketFrameSize(1000000);
 options.setMaxWebsocketMessageSize(1000000);
 
 client = vertx.createHttpClient(options);
 connectToBittrex(endPoint);
}
 
开发者ID:AlxGDev,项目名称:BittrexGatherer,代码行数:23,代码来源:BittrexRemoteVerticle.java

示例2: createStreamUrl

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
private String createStreamUrl(HttpServletRequest request, Player player, int id, int offset, int duration, Pair<Integer, Dimension> bitRate) {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(getContextPath(request) + "ext/stream/stream.ts");
    builder.queryParam("id", id);
    builder.queryParam("hls", "true");
    builder.queryParam("timeOffset", offset);
    builder.queryParam("player", player.getId());
    builder.queryParam("duration", duration);
    if (bitRate != null) {
        builder.queryParam("maxBitRate", bitRate.getFirst());
        Dimension dimension = bitRate.getSecond();
        if (dimension != null) {
            builder.queryParam("size", dimension.width);
            builder.queryParam("x", dimension.height);
        }
    }
    jwtSecurityService.addJWTToken(builder);
    return builder.toUriString();
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:19,代码来源:HLSController.java

示例3: addJWTToken

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
@Test
public void addJWTToken() throws Exception {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uriString);
    String actualUri = service.addJWTToken(builder).build().toUriString();
    String jwtToken = UriComponentsBuilder.fromUriString(actualUri).build().getQueryParams().getFirst(
            JWTSecurityService.JWT_PARAM_NAME);
    DecodedJWT verify = verifier.verify(jwtToken);
    Claim claim = verify.getClaim(JWTSecurityService.CLAIM_PATH);
    assertEquals(expectedClaimString, claim.asString());
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:11,代码来源:JWTSecurityServiceTest.java

示例4: url

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
public static URI url(String...xs) {
    UriComponentsBuilder builder = UriComponentsBuilder
                                  .fromUriString("http://localhost:8000/");
    String[] ys = Arrayz.op(String[]::new).intersperse(() -> "/", xs);
    Arrays.asList(ys).forEach(builder::path);
    return builder.build().toUri();
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:8,代码来源:BaseWebTest.java

示例5: getURL

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
/**
 * Gets the URL for the client's HTTP request.
 * <p/>
 * 
 * @param uriVariables a Map of URI path variables to values in order to expand the URI template
 *        into a URI.
 * @return a URL as a URI referring to the location of the resource requested by the client via
 *         HTTP.
 * @see #getURI()
 * @see java.net.URI
 * @see org.springframework.web.util.UriComponents
 * @see org.springframework.web.util.UriComponentsBuilder
 */
public URI getURL(final Map<String, ?> uriVariables) {
  final UriComponentsBuilder uriBuilder =
      UriComponentsBuilder.fromUriString(UriUtils.decode(getURI().toString()));

  if (isGet() || isDelete()) {
    final List<String> pathVariables = getPathVariables();

    // get query parameters to append to the URI/URL based on the request parameters that are not
    // path variables...
    final Map<String, List<Object>> queryParameters =
        CollectionUtils.removeKeys(new LinkedMultiValueMap<String, Object>(getParameters()),
            new Filter<Map.Entry<String, List<Object>>>() {
              @Override
              public boolean accept(final Map.Entry<String, List<Object>> entry) {
                // GEODE-1469: since stepArgs has json string in there, we will need to encode it
                // so that it won't interfere with the expand() call afterwards
                if (entry.getKey().contains(CLIMultiStepHelper.STEP_ARGS)) {
                  List<Object> stepArgsList = entry.getValue();
                  if (stepArgsList != null) {
                    String stepArgs = (String) stepArgsList.remove(0);
                    stepArgsList.add(UriUtils.encode(stepArgs));
                  }
                }
                return !pathVariables.contains(entry.getKey());
              }
            });

    for (final String queryParameterName : queryParameters.keySet()) {
      uriBuilder.queryParam(queryParameterName,
          getParameters().get(queryParameterName).toArray());
    }
  }

  return uriBuilder.build().expand(UriUtils.encode(new HashMap<String, Object>(uriVariables)))
      .encode().toUri();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:50,代码来源:ClientHttpRequest.java

示例6: invoke

import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
@Override
public <T, R> ResponseEntity<T> invoke(RequestDefinition requestDefinition, HttpMethod method,
		RequestEntity<R> requestEntity, ResponseType<T> responseType, boolean onlySuccessfulStatusCode) {

	// URI
	final UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(requestDefinition.getRequestURI());
	// query parameters
	requestDefinition.getQueryParameters().forEach((n, v) -> builder.queryParam(n, v));
	// template parameters
	final String uri = builder.buildAndExpand(requestDefinition.getTemplateParameters()).toUriString();

	// headers
	HttpHeaders headers = new HttpHeaders();
	requestDefinition.getHeaders().forEach((n, v) -> headers.add(n, v));

	// Entity
	HttpEntity<?> entity = new HttpEntity<>(getRequestPayload(requestEntity), headers);

	// method
	org.springframework.http.HttpMethod requestMethod = org.springframework.http.HttpMethod
			.resolve(method.getMethodName());
	if (requestMethod == null) {
		throw new RestClientException("Unsupported HTTP method: " + method.getMethodName());
	}

	// get response, checking propertySet
	final org.springframework.http.ResponseEntity<Resource> response;
	if (requestDefinition.getPropertySet().isPresent()) {
		response = requestDefinition.getPropertySet().get()
				.execute(() -> invoke(uri, requestMethod, entity, responseType));
	} else {
		response = invoke(uri, requestMethod, entity, responseType);
	}

	// check error status code
	int statusCode = response.getStatusCodeValue();

	if (onlySuccessfulStatusCode && !HttpStatus.isSuccessStatusCode(statusCode)) {
		throw new UnsuccessfulResponseException(new SpringResponseEntity<>(response, ResponseType.of(byte[].class),
				getRestTemplate().getMessageConverters(), requestDefinition.getPropertySet().orElse(null)));
	}

	return new SpringResponseEntity<>(response, responseType, getRestTemplate().getMessageConverters(),
			requestDefinition.getPropertySet().orElse(null));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:46,代码来源:RestTemplateRestClient.java


注:本文中的org.springframework.web.util.UriComponentsBuilder.fromUriString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。