|
|
|
@ -17,8 +17,6 @@
|
|
|
|
|
package org.springframework.boot.autoconfigure.web.reactive;
|
|
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
@ -51,7 +49,6 @@ import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
|
import org.springframework.format.FormatterRegistry;
|
|
|
|
|
import org.springframework.format.support.FormattingConversionService;
|
|
|
|
|
import org.springframework.http.codec.ServerCodecConfigurer;
|
|
|
|
@ -154,14 +151,12 @@ public class WebFluxAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
private final ObjectProvider<ViewResolver> viewResolvers;
|
|
|
|
|
|
|
|
|
|
private final ResourceLoader resourceLoader;
|
|
|
|
|
|
|
|
|
|
public WebFluxConfig(org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
|
|
|
|
|
WebProperties webProperties, WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory,
|
|
|
|
|
ObjectProvider<HandlerMethodArgumentResolver> resolvers,
|
|
|
|
|
ObjectProvider<CodecCustomizer> codecCustomizers,
|
|
|
|
|
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizer,
|
|
|
|
|
ObjectProvider<ViewResolver> viewResolvers, ResourceLoader resourceLoader) {
|
|
|
|
|
ObjectProvider<ViewResolver> viewResolvers) {
|
|
|
|
|
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
|
|
|
|
|
: webProperties.getResources();
|
|
|
|
|
this.webFluxProperties = webFluxProperties;
|
|
|
|
@ -170,7 +165,6 @@ public class WebFluxAutoConfiguration {
|
|
|
|
|
this.codecCustomizers = codecCustomizers;
|
|
|
|
|
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizer.getIfAvailable();
|
|
|
|
|
this.viewResolvers = viewResolvers;
|
|
|
|
|
this.resourceLoader = resourceLoader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -190,28 +184,17 @@ public class WebFluxAutoConfiguration {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!registry.hasMappingForPattern("/webjars/**")) {
|
|
|
|
|
String webjarsLocation = "classpath:/META-INF/resources/webjars/";
|
|
|
|
|
if (this.resourceLoader.getResource(webjarsLocation).exists()) {
|
|
|
|
|
ResourceHandlerRegistration registration = registry.addResourceHandler("/webjars/**")
|
|
|
|
|
.addResourceLocations(webjarsLocation);
|
|
|
|
|
configureResourceCaching(registration);
|
|
|
|
|
customizeResourceHandlerRegistration(registration);
|
|
|
|
|
}
|
|
|
|
|
ResourceHandlerRegistration registration = registry.addResourceHandler("/webjars/**")
|
|
|
|
|
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
|
|
configureResourceCaching(registration);
|
|
|
|
|
customizeResourceHandlerRegistration(registration);
|
|
|
|
|
}
|
|
|
|
|
String staticPathPattern = this.webFluxProperties.getStaticPathPattern();
|
|
|
|
|
if (!registry.hasMappingForPattern(staticPathPattern)) {
|
|
|
|
|
List<String> foundLocations = new ArrayList<>();
|
|
|
|
|
for (String staticLocation : this.resourceProperties.getStaticLocations()) {
|
|
|
|
|
if (this.resourceLoader.getResource(staticLocation).exists()) {
|
|
|
|
|
foundLocations.add(staticLocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!foundLocations.isEmpty()) {
|
|
|
|
|
ResourceHandlerRegistration registration = registry.addResourceHandler(staticPathPattern)
|
|
|
|
|
.addResourceLocations(foundLocations.toArray(new String[0]));
|
|
|
|
|
configureResourceCaching(registration);
|
|
|
|
|
customizeResourceHandlerRegistration(registration);
|
|
|
|
|
}
|
|
|
|
|
ResourceHandlerRegistration registration = registry.addResourceHandler(staticPathPattern)
|
|
|
|
|
.addResourceLocations(this.resourceProperties.getStaticLocations());
|
|
|
|
|
configureResourceCaching(registration);
|
|
|
|
|
customizeResourceHandlerRegistration(registration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|