Example usage for org.springframework.http.server PathContainer parsePath

List of usage examples for org.springframework.http.server PathContainer parsePath

Introduction

In this page you can find the example usage for org.springframework.http.server PathContainer parsePath.

Prototype

static PathContainer parsePath(String path) 

Source Link

Document

Parse the path value into a sequence of "/" Separator Separator and PathSegment PathSegment elements.

Usage

From source file:org.springframework.web.reactive.resource.ResourceUrlProvider.java

/**
 * Get the public resource URL for the given URI string.
 * <p>The URI string is expected to be a path and if it contains a query or
 * fragment those will be preserved in the resulting public resource URL.
 * @param uriString the URI string to transform
 * @param exchange the current exchange//  ww  w. j av  a2  s.c  o  m
 * @return the resolved public resource URL path, or empty if unresolved
 */
public final Mono<String> getForUriString(String uriString, ServerWebExchange exchange) {
    if (logger.isTraceEnabled()) {
        logger.trace("Getting resource URL for request URL \"" + uriString + "\"");
    }
    ServerHttpRequest request = exchange.getRequest();
    int queryIndex = getQueryIndex(uriString);
    String lookupPath = uriString.substring(0, queryIndex);
    String query = uriString.substring(queryIndex);
    PathContainer parsedLookupPath = PathContainer.parsePath(lookupPath);
    if (logger.isTraceEnabled()) {
        logger.trace("Getting resource URL for lookup path \"" + lookupPath + "\"");
    }
    return resolveResourceUrl(parsedLookupPath)
            .map(resolvedPath -> request.getPath().contextPath().value() + resolvedPath + query);
}