Polish use of LookupPath

This commit is contained in:
Rossen Stoyanchev
2017-06-02 14:46:34 -04:00
parent 90df7dd279
commit a7020e419a
11 changed files with 67 additions and 63 deletions

View File

@@ -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();

View File

@@ -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;
}