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 */ 016 017package org.springframework.web.reactive.resource; 018 019import reactor.core.publisher.Mono; 020 021import org.springframework.core.io.Resource; 022import org.springframework.lang.Nullable; 023 024/** 025 * A strategy to determine the version of a static resource and to apply and/or 026 * extract it from the URL path. 027 * 028 * @author Rossen Stoyanchev 029 * @author Brian Clozel 030 * @since 5.0 031 * @see VersionResourceResolver 032*/ 033public interface VersionStrategy { 034 035 /** 036 * Extract the resource version from the request path. 037 * @param requestPath the request path to check 038 * @return the version string or {@code null} if none was found 039 */ 040 @Nullable 041 String extractVersion(String requestPath); 042 043 /** 044 * Remove the version from the request path. It is assumed that the given 045 * version was extracted via {@link #extractVersion(String)}. 046 * @param requestPath the request path of the resource being resolved 047 * @param version the version obtained from {@link #extractVersion(String)} 048 * @return the request path with the version removed 049 */ 050 String removeVersion(String requestPath, String version); 051 052 /** 053 * Add a version to the given request path. 054 * @param requestPath the requestPath 055 * @param version the version 056 * @return the requestPath updated with a version string 057 */ 058 String addVersion(String requestPath, String version); 059 060 /** 061 * Determine the version for the given resource. 062 * @param resource the resource to check 063 * @return the resource version 064 */ 065 Mono<String> getResourceVersion(Resource resource); 066 067}