001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.http.server; 017 018import java.net.URI; 019 020import org.springframework.lang.Nullable; 021 022/** 023 * Represents the complete path for a request. 024 * 025 * @author Rossen Stoyanchev 026 * @since 5.0 027 */ 028public interface RequestPath extends PathContainer { 029 030 /** 031 * Returns the portion of the URL path that represents the application. 032 * The context path is always at the beginning of the path and starts but 033 * does not end with "/". It is shared for URLs of the same application. 034 * <p>The context path may come from the underlying runtime API such as 035 * when deploying as a WAR to a Servlet container or it may be assigned in 036 * a WebFlux application through the use of 037 * {@link org.springframework.http.server.reactive.ContextPathCompositeHandler 038 * ContextPathCompositeHandler}. 039 */ 040 PathContainer contextPath(); 041 042 /** 043 * The portion of the request path after the context path. 044 */ 045 PathContainer pathWithinApplication(); 046 047 /** 048 * Return a new {@code RequestPath} instance with a modified context path. 049 * The new context path must match 0 or more path segments at the start. 050 * @param contextPath the new context path 051 * @return a new {@code RequestPath} instance 052 */ 053 RequestPath modifyContextPath(String contextPath); 054 055 056 /** 057 * Create a new {@code RequestPath} with the given parameters. 058 */ 059 static RequestPath parse(URI uri, @Nullable String contextPath) { 060 return new DefaultRequestPath(uri, contextPath); 061 } 062 063}