Example usage for org.springframework.http.server.reactive ServerHttpRequest getPath

List of usage examples for org.springframework.http.server.reactive ServerHttpRequest getPath

Introduction

In this page you can find the example usage for org.springframework.http.server.reactive ServerHttpRequest getPath.

Prototype

RequestPath getPath();

Source Link

Document

Returns a structured representation of the request path including the context path + path within application portions, path segments with encoded and decoded values, and path parameters.

Usage

From source file:org.springframework.security.web.server.savedrequest.WebSessionServerRequestCache.java

private static String pathInApplication(ServerHttpRequest request) {
    String path = request.getPath().pathWithinApplication().value();
    String query = request.getURI().getRawQuery();
    return path + (query != null ? "?" + query : "");
}

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//from   www .  jav  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);
}