Polish use of LookupPath
This commit is contained in:
@@ -80,7 +80,9 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
||||
|
||||
@Override
|
||||
public CorsConfiguration getCorsConfiguration(ServerWebExchange exchange) {
|
||||
String lookupPath = exchange.<LookupPath>getAttribute(LookupPath.LOOKUP_PATH_ATTRIBUTE).get().getPath();
|
||||
String lookupPath = exchange.<LookupPath>getAttribute(LookupPath.LOOKUP_PATH_ATTRIBUTE)
|
||||
.map(LookupPath::getPath)
|
||||
.orElseThrow(() -> new IllegalStateException("No LookupPath attribute."));
|
||||
for (Map.Entry<String, CorsConfiguration> entry : this.corsConfigurations.entrySet()) {
|
||||
if (this.pathMatcher.match(entry.getKey(), lookupPath)) {
|
||||
return entry.getValue();
|
||||
|
||||
@@ -29,18 +29,21 @@ public final class LookupPath {
|
||||
|
||||
public static final String LOOKUP_PATH_ATTRIBUTE = LookupPath.class.getName();
|
||||
|
||||
|
||||
private final String path;
|
||||
|
||||
private final int fileExtStartIndex;
|
||||
|
||||
private final int fileExtEndIndex;
|
||||
|
||||
|
||||
public LookupPath(String path, int fileExtStartIndex, int fileExtEndIndex) {
|
||||
this.path = path;
|
||||
this.fileExtStartIndex = fileExtStartIndex;
|
||||
this.fileExtEndIndex = fileExtEndIndex;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user