001/*
002 * Copyright 2002-2015 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 */
016
017package org.springframework.web.servlet.resource;
018
019/**
020 * A strategy for extracting and embedding a resource version in its URL path.
021 *
022 * @author Brian Clozel
023 * @author Rossen Stoyanchev
024 * @since 4.1
025*/
026public interface VersionPathStrategy {
027
028        /**
029         * Extract the resource version from the request path.
030         * @param requestPath the request path to check
031         * @return the version string or {@code null} if none was found
032         */
033        String extractVersion(String requestPath);
034
035        /**
036         * Remove the version from the request path. It is assumed that the given
037         * version was extracted via {@link #extractVersion(String)}.
038         * @param requestPath the request path of the resource being resolved
039         * @param version the version obtained from {@link #extractVersion(String)}
040         * @return the request path with the version removed
041         */
042        String removeVersion(String requestPath, String version);
043
044        /**
045         * Add a version to the given request path.
046         * @param requestPath the requestPath
047         * @param version the version
048         * @return the requestPath updated with a version string
049         */
050        String addVersion(String requestPath, String version);
051
052}