Package org.springframework.web.util

Examples of org.springframework.web.util.UriTemplate


        String url = resolveUrl(path, uriVariables);
        return restClient.post(gitHub.restOperations(), url, String.class, body);
    }

    private String resolveUrl(String path, Object[] uriVariables) {
        String expandedPath = new UriTemplate(path).expand(uriVariables).toString();
        return API_URL_BASE + expandedPath;
    }
View Full Code Here


    public String sendPostRequestForHtml(String path, String body, Object... uriVariables) {
        return "<h1>HTML</h1>";
    }

    private String handleRequest(String path, Object[] uriVariables) {
        String url = new UriTemplate(path).expand(uriVariables).getPath();
        if (!responseMap.containsKey(url)) {
            throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "no response for: " + url);
        }
        return responseMap.get(url);
    }
View Full Code Here

  public static ControllerLinkBuilder linkTo(Class<?> controller, Method method, Object... parameters) {

    Assert.notNull(controller, "Controller type must not be null!");
    Assert.notNull(method, "Method must not be null!");

    UriTemplate template = new UriTemplate(DISCOVERER.getMapping(controller, method));
    URI uri = template.expand(parameters);

    return new ControllerLinkBuilder(getBuilder()).slash(uri);
  }
View Full Code Here

    Method method = invocation.getMethod();

    String mapping = DISCOVERER.getMapping(invocation.getTargetType(), method);
    UriComponentsBuilder builder = ControllerLinkBuilder.getBuilder().path(mapping);

    UriTemplate template = new UriTemplate(mapping);
    Map<String, Object> values = new HashMap<String, Object>();

    Iterator<String> names = template.getVariableNames().iterator();
    while (classMappingParameters.hasNext()) {
      values.put(names.next(), classMappingParameters.next());
    }

    for (BoundMethodParameter parameter : PATH_VARIABLE_ACCESSOR.getBoundParameters(invocation)) {
View Full Code Here

  @Override
  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  @Override
  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getContextUrl(String, Map)
   */
  public String getContextUrl(String relativeUrl, Map<String,String> params) {
    UriTemplate template = new UriTemplate(relativeUrl);
    return getContextPath() + template.expand(params).toASCIIString();
  }
View Full Code Here

  @Override
  public <T> ListenableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  @Override
  public <T> ListenableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

   * @param params a map of parameters to insert as placeholders in the url
   * @return a URL that points back to the server with an absolute path (also URL-encoded accordingly)
   */
  public String getContextUrl(String relativeUrl, Map<String, ?> params) {
    String url = getContextPath() + relativeUrl;
    UriTemplate template = new UriTemplate(url);
    url = template.expand(params).toASCIIString();
    if (this.response != null) {
      url = this.response.encodeURL(url);
    }
    return url;
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.